mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -16,16 +16,11 @@ use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use DateTime;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Faker\Factory as FakerFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Load reports into DB.
|
||||
@@ -49,7 +44,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
{
|
||||
$this->createExpected($manager);
|
||||
|
||||
//create random 2 times, to allow multiple report on some people
|
||||
// create random 2 times, to allow multiple report on some people
|
||||
$this->createRandom($manager, 90);
|
||||
$this->createRandom($manager, 30);
|
||||
|
||||
@@ -66,7 +61,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$report = (new Report())
|
||||
->setPerson($charline)
|
||||
->setCFGroup($this->getReference('cf_group_report_logement'))
|
||||
->setDate(new DateTime('2015-01-05'))
|
||||
->setDate(new \DateTime('2015-01-05'))
|
||||
->setScope($this->getReference('scope_social'));
|
||||
$this->fillReport($report);
|
||||
|
||||
@@ -81,7 +76,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$people = $this->getPeopleRandom($percentage);
|
||||
|
||||
foreach ($people as $person) {
|
||||
//create a report, set logement or education report
|
||||
// create a report, set logement or education report
|
||||
$report = (new Report())
|
||||
->setPerson($person)
|
||||
->setCFGroup(
|
||||
@@ -97,16 +92,16 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
|
||||
private function fillReport(Report $report)
|
||||
{
|
||||
//setUser
|
||||
// setUser
|
||||
$usernameRef = array_rand(LoadUsers::$refs);
|
||||
$report->setUser(
|
||||
$this->getReference($usernameRef)
|
||||
);
|
||||
|
||||
//set date if null
|
||||
if ($report->getDate() === null) {
|
||||
//set date. 30% of the dates are 2015-05-01
|
||||
$expectedDate = new DateTime('2015-01-05');
|
||||
// set date if null
|
||||
if (null === $report->getDate()) {
|
||||
// set date. 30% of the dates are 2015-05-01
|
||||
$expectedDate = new \DateTime('2015-01-05');
|
||||
|
||||
if (random_int(0, 100) < 30) {
|
||||
$report->setDate($expectedDate);
|
||||
@@ -116,7 +111,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
}
|
||||
}
|
||||
|
||||
//fill data
|
||||
// fill data
|
||||
$datas = [];
|
||||
|
||||
foreach ($report->getCFGroup()->getCustomFields() as $field) {
|
||||
@@ -148,7 +143,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
->getRepository(Person::class)
|
||||
->findAll();
|
||||
|
||||
//keep only a part ($percentage) of the people
|
||||
// keep only a part ($percentage) of the people
|
||||
$selectedPeople = [];
|
||||
|
||||
foreach ($people as $person) {
|
||||
@@ -171,16 +166,16 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$multiple = $field->getOptions()['multiple'];
|
||||
$other = $field->getOptions()['other'];
|
||||
|
||||
//add other if allowed
|
||||
// add other if allowed
|
||||
if ($other) {
|
||||
$choices[] = ['slug' => '_other'];
|
||||
}
|
||||
|
||||
//initialize results
|
||||
// initialize results
|
||||
$picked = [];
|
||||
|
||||
if ($multiple) {
|
||||
$numberSelected = random_int(1, count($choices) - 1);
|
||||
$numberSelected = random_int(1, \count($choices) - 1);
|
||||
|
||||
for ($i = 0; $i < $numberSelected; ++$i) {
|
||||
$picked[] = $this->pickChoice($choices);
|
||||
@@ -189,7 +184,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
|
||||
if ($other) {
|
||||
$result = ['_other' => null, '_choices' => $picked];
|
||||
|
||||
if (in_array('_other', $picked, true)) {
|
||||
if (\in_array('_other', $picked, true)) {
|
||||
$result['_other'] = $this->faker->realText(70);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user