Skip to content

Commit

Permalink
Make NativeLoader non-final and changed its API (nelmio#681)
Browse files Browse the repository at this point in the history
- Made NativeLoader non-final
- Removed "BuiltIn" from the method names
  • Loading branch information
dantleech authored and theofidry committed Mar 7, 2017
1 parent 8cd71be commit 4acd0d6
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 85 deletions.
160 changes: 80 additions & 80 deletions src/Loader/NativeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,41 +152,41 @@
* Loader implementation made to be usable without any dependency injection for quick and easy usage. For more advanced
* usages, use {@see \Nelmio\Alice\Loader\SimpleFileLoader} instead or implement your own loader.
*
* @method DataLoaderInterface getBuiltInDataLoader()
* @method FileLoaderInterface getBuiltInFileLoader()
* @method DataLoaderInterface getDataLoader()
* @method FileLoaderInterface getFileLoader()
*
* @method FixtureBuilderInterface getBuiltInFixtureBuilder()
* @method GeneratorInterface getBuiltInGenerator()
* @method ParserInterface getBuiltInParser()
* @method FixtureBuilderInterface getFixtureBuilder()
* @method GeneratorInterface getGenerator()
* @method ParserInterface getParser()
*
* @method DenormalizerInterface getBuiltInDenormalizer()
* @method FixtureBagDenormalizerInterface getBuiltInFixtureBagDenormalizer
* @method FixtureDenormalizerInterface getBuiltInFixtureDenormalizer()
* @method FlagParserInterface getBuiltInFlagParser()
* @method ConstructorDenormalizerInterface getBuiltInConstructorDenormalizer()
* @method PropertyDenormalizerInterface getBuiltInPropertyDenormalizer()
* @method CallsDenormalizerInterface getBuiltInCallsDenormalizer()
* @method ArgumentsDenormalizerInterface getBuiltInArgumentsDenormalizer()
* @method ValueDenormalizerInterface getBuiltInValueDenormalizer()
* @method DenormalizerInterface getDenormalizer()
* @method FixtureBagDenormalizerInterface getFixtureBagDenormalizer
* @method FixtureDenormalizerInterface getFixtureDenormalizer()
* @method FlagParserInterface getFlagParser()
* @method ConstructorDenormalizerInterface getConstructorDenormalizer()
* @method PropertyDenormalizerInterface getPropertyDenormalizer()
* @method CallsDenormalizerInterface getCallsDenormalizer()
* @method ArgumentsDenormalizerInterface getArgumentsDenormalizer()
* @method ValueDenormalizerInterface getValueDenormalizer()
*
* @method ExpressionLanguageParserInterface getBuiltInExpressionLanguageParser()
* @method LexerInterface getBuiltInLexer()
* @method TokenParserInterface getBuiltInExpressionLanguageTokenParser()
* @method ExpressionLanguageParserInterface getExpressionLanguageParser()
* @method LexerInterface getLexer()
* @method TokenParserInterface getExpressionLanguageTokenParser()
*
* @method ObjectGeneratorInterface getBuiltInObjectGenerator()
* @method ObjectGeneratorInterface getObjectGenerator()
*
* @method FixtureSetResolverInterface getBuiltInFixtureSetResolver()
* @method ParameterBagResolverInterface getBuiltInParameterResolver()
* @method ValueResolverInterface getBuiltInValueResolver()
* @method FixtureSetResolverInterface getFixtureSetResolver()
* @method ParameterBagResolverInterface getParameterResolver()
* @method ValueResolverInterface getValueResolver()
* @method FakerGenerator getFakerGenerator()
*
* @method InstantiatorInterface getBuiltInInstantiator()
* @method HydratorInterface getBuiltInHydrator()
* @method PropertyHydratorInterface getBuiltInPropertyHydrator()
* @method InstantiatorInterface getInstantiator()
* @method HydratorInterface getHydrator()
* @method PropertyHydratorInterface getPropertyHydrator()
* @method PropertyAccessorInterface getPropertyAccessor()
* @method CallerInterface getBuiltInCaller()
* @method CallerInterface getCaller()
*/
final class NativeLoader implements FileLoaderInterface, DataLoaderInterface
class NativeLoader implements FileLoaderInterface, DataLoaderInterface
{
use IsAServiceTrait;

Expand Down Expand Up @@ -215,8 +215,8 @@ final class NativeLoader implements FileLoaderInterface, DataLoaderInterface
public function __construct(FakerGenerator $fakerGenerator = null)
{
$this->fakerGenerator = (null === $fakerGenerator) ? $this->getFakerGenerator() : $fakerGenerator;
$this->dataLoader = $this->getBuiltInDataLoader();
$this->fileLoader = $this->getBuiltInFileLoader();
$this->dataLoader = $this->getDataLoader();
$this->fileLoader = $this->getFileLoader();
}

/**
Expand All @@ -235,38 +235,38 @@ public function loadData(array $data, array $parameters = [], array $objects = [
return $this->dataLoader->loadData($data, $parameters, $objects);
}

protected function createBuiltInDataLoader(): DataLoaderInterface
protected function createDataLoader(): DataLoaderInterface
{
return new SimpleDataLoader(
$this->getBuiltInFixtureBuilder(),
$this->getBuiltInGenerator()
$this->getFixtureBuilder(),
$this->getGenerator()
);
}

protected function createBuiltInFileLoader(): FileLoaderInterface
protected function createFileLoader(): FileLoaderInterface
{
return new SimpleFileLoader(
$this->getBuiltInParser(),
$this->getParser(),
$this->dataLoader
);
}

protected function createBuiltInFixtureBuilder(): FixtureBuilderInterface
protected function createFixtureBuilder(): FixtureBuilderInterface
{
return new SimpleBuilder(
$this->getBuiltInDenormalizer()
$this->getDenormalizer()
);
}

protected function createBuiltInGenerator(): GeneratorInterface
protected function createGenerator(): GeneratorInterface
{
return new DoublePassGenerator(
$this->getBuiltInFixtureSetResolver(),
$this->getBuiltInObjectGenerator()
$this->getFixtureSetResolver(),
$this->getObjectGenerator()
);
}

protected function createBuiltInParser(): ParserInterface
protected function createParser(): ParserInterface
{
$registry = new ParserRegistry([
new YamlParser(new SymfonyYamlParser()),
Expand All @@ -282,32 +282,32 @@ protected function createBuiltInParser(): ParserInterface
);
}

protected function createBuiltInDenormalizer(): DenormalizerInterface
protected function createDenormalizer(): DenormalizerInterface
{
return new SimpleDenormalizer(
new SimpleParameterBagDenormalizer(),
$this->getBuiltInFixtureBagDenormalizer()
$this->getFixtureBagDenormalizer()
);
}

protected function createBuiltInFixtureBagDenormalizer(): FixtureBagDenormalizerInterface
protected function createFixtureBagDenormalizer(): FixtureBagDenormalizerInterface
{
return new SimpleFixtureBagDenormalizer(
$this->getBuiltInFixtureDenormalizer(),
$this->getBuiltInFlagParser()
$this->getFixtureDenormalizer(),
$this->getFlagParser()
);
}

protected function createBuiltInFixtureDenormalizer(): FixtureDenormalizerInterface
protected function createFixtureDenormalizer(): FixtureDenormalizerInterface
{
return new FixtureDenormalizerRegistry(
$this->getBuiltInFlagParser(),
$this->getFlagParser(),
[
new \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\SimpleDenormalizer(
new SimpleSpecificationsDenormalizer(
$this->getBuiltInConstructorDenormalizer(),
$this->getBuiltInPropertyDenormalizer(),
$this->getBuiltInCallsDenormalizer()
$this->getConstructorDenormalizer(),
$this->getPropertyDenormalizer(),
$this->getCallsDenormalizer()
)
),
new SimpleCollectionDenormalizer(
Expand All @@ -324,7 +324,7 @@ protected function createBuiltInFixtureDenormalizer(): FixtureDenormalizerInterf
);
}

protected function createBuiltInFlagParser(): FlagParserInterface
protected function createFlagParser(): FlagParserInterface
{
$registry = new FlagParserRegistry([
new ExtendFlagParser(),
Expand All @@ -336,58 +336,58 @@ protected function createBuiltInFlagParser(): FlagParserInterface
return new ElementFlagParser($registry);
}

protected function createBuiltInConstructorDenormalizer(): ConstructorDenormalizerInterface
protected function createConstructorDenormalizer(): ConstructorDenormalizerInterface
{
return new ConstructorWithCallerDenormalizer(
new SimpleConstructorDenormalizer(
$this->getBuiltInArgumentsDenormalizer()
$this->getArgumentsDenormalizer()
)
);
}

protected function createBuiltInPropertyDenormalizer(): PropertyDenormalizerInterface
protected function createPropertyDenormalizer(): PropertyDenormalizerInterface
{
return new SimplePropertyDenormalizer(
$this->getBuiltInValueDenormalizer()
$this->getValueDenormalizer()
);
}

protected function createBuiltInCallsDenormalizer(): CallsDenormalizerInterface
protected function createCallsDenormalizer(): CallsDenormalizerInterface
{
return new OptionalCallsDenormalizer(
$this->getBuiltInArgumentsDenormalizer()
$this->getArgumentsDenormalizer()
);
}

protected function createBuiltInArgumentsDenormalizer(): ArgumentsDenormalizerInterface
protected function createArgumentsDenormalizer(): ArgumentsDenormalizerInterface
{
return new SimpleArgumentsDenormalizer(
$this->getBuiltInValueDenormalizer()
$this->getValueDenormalizer()
);
}

protected function createBuiltInValueDenormalizer(): ValueDenormalizerInterface
protected function createValueDenormalizer(): ValueDenormalizerInterface
{
return new UniqueValueDenormalizer(
new SimpleValueDenormalizer(
$this->getBuiltInExpressionLanguageParser()
$this->getExpressionLanguageParser()
)
);
}

protected function createBuiltInExpressionLanguageParser(): ExpressionLanguageParserInterface
protected function createExpressionLanguageParser(): ExpressionLanguageParserInterface
{
return new FunctionFixtureReferenceParser(
new StringMergerParser(
new SimpleParser(
$this->getBuiltInLexer(),
$this->getBuiltInExpressionLanguageTokenParser()
$this->getLexer(),
$this->getExpressionLanguageTokenParser()
)
)
);
}

protected function createBuiltInLexer(): LexerInterface
protected function createLexer(): LexerInterface
{
return new EmptyValueLexer(
new ReferenceEscaperLexer(
Expand All @@ -402,7 +402,7 @@ protected function createBuiltInLexer(): LexerInterface
);
}

protected function createBuiltInExpressionLanguageTokenParser(): TokenParserInterface
protected function createExpressionLanguageTokenParser(): TokenParserInterface
{
return new TokenParserRegistry([
new DynamicArrayTokenParser(),
Expand Down Expand Up @@ -430,29 +430,29 @@ protected function createBuiltInExpressionLanguageTokenParser(): TokenParserInte
]);
}

protected function createBuiltInObjectGenerator(): ObjectGeneratorInterface
protected function createObjectGenerator(): ObjectGeneratorInterface
{
return new CompleteObjectGenerator(
new SimpleObjectGenerator(
$this->getBuiltInValueResolver(),
$this->getBuiltInInstantiator(),
$this->getBuiltInHydrator(),
$this->getBuiltInCaller()
$this->getValueResolver(),
$this->getInstantiator(),
$this->getHydrator(),
$this->getCaller()
)
);
}

protected function createBuiltInFixtureSetResolver(): FixtureSetResolverInterface
protected function createFixtureSetResolver(): FixtureSetResolverInterface
{
return new RemoveConflictingObjectsResolver(
new SimpleFixtureSetResolver(
$this->getBuiltInParameterResolver(),
$this->getParameterResolver(),
new TemplateFixtureBagResolver()
)
);
}

protected function createBuiltInParameterResolver(): ParameterBagResolverInterface
protected function createParameterResolver(): ParameterBagResolverInterface
{
$registry = new ParameterResolverRegistry([
new StaticParameterResolver(),
Expand All @@ -465,7 +465,7 @@ protected function createBuiltInParameterResolver(): ParameterBagResolverInterfa
);
}

protected function createBuiltInValueResolver(): ValueResolverInterface
protected function createValueResolver(): ValueResolverInterface
{
return new ValueResolverRegistry([
new ArrayValueResolver(),
Expand Down Expand Up @@ -516,7 +516,7 @@ protected function createFakerGenerator(): FakerGenerator
return $generator;
}

protected function createBuiltInInstantiator(): InstantiatorInterface
protected function createInstantiator(): InstantiatorInterface
{
return new ExistingInstanceInstantiator(
new InstantiatorResolver(
Expand All @@ -530,14 +530,14 @@ protected function createBuiltInInstantiator(): InstantiatorInterface
);
}

protected function createBuiltInHydrator(): HydratorInterface
protected function createHydrator(): HydratorInterface
{
return new SimpleHydrator(
$this->getBuiltInPropertyHydrator()
$this->getPropertyHydrator()
);
}

protected function createBuiltInPropertyHydrator(): PropertyHydratorInterface
protected function createPropertyHydrator(): PropertyHydratorInterface
{
return new SymfonyPropertyAccessorHydrator(
$this->getPropertyAccessor()
Expand All @@ -553,9 +553,9 @@ protected function createPropertyAccessor(): PropertyAccessorInterface
);
}

protected function createBuiltInCaller(): CallerInterface
protected function createCaller(): CallerInterface
{
return new SimpleCaller($this->getBuiltInValueResolver());
return new SimpleCaller($this->getValueResolver());
}

public function __call(string $method, array $arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LexerIntegrationTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
$this->lexer = (new NativeLoader())->getBuiltInLexer();
$this->lexer = (new NativeLoader())->getLexer();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ParserIntegrationTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
$this->parser = (new NativeLoader())->getBuiltInExpressionLanguageParser();
$this->parser = (new NativeLoader())->getExpressionLanguageParser();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ParameterResolverIntegrationTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
$this->resolver = (new NativeLoader())->getBuiltInParameterResolver();
$this->resolver = (new NativeLoader())->getParameterResolver();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Loader/NativeLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function testThrowsAnExceptionIfCallUnknownGetMethod()
public function testAlwaysReturnsTheSameService()
{
$loader = new NativeLoader();
$fileLoader1 = $loader->getBuiltInFileLoader();
$fileLoader2 = $loader->getBuiltInFileLoader();
$fileLoader1 = $loader->getFileLoader();
$fileLoader2 = $loader->getFileLoader();

$this->assertSame($fileLoader1, $fileLoader2);
}
Expand Down

0 comments on commit 4acd0d6

Please sign in to comment.