for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of monofony.
*
* (c) Mobizel
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\Fixture\Factory;
use App\Entity\Article;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ArticleExampleFactory extends AbstractExampleFactory
{
/**
* @var FactoryInterface
private $articleFactory;
* @var \Faker\Generator
private $faker;
* @var OptionsResolver
private $optionsResolver;
* @param FactoryInterface $articleFactory
public function __construct(FactoryInterface $articleFactory)
$this->articleFactory = $articleFactory;
$this->faker = \Faker\Factory::create();
$this->optionsResolver = new OptionsResolver();
$this->configureOptions($this->optionsResolver);
}
* {@inheritdoc}
protected function configureOptions(OptionsResolver $resolver)
$resolver
->setDefault('title', function (Options $options) {
$options
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return ucfirst($this->faker->words(3, true));
});
public function create(array $options = [])
$options = $this->optionsResolver->resolve($options);
/** @var Article $article */
$article = $this->articleFactory->createNew();
$article->setTitle($options['title']);
return $article;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.