mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 16:45:01 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
@@ -29,13 +28,9 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Repository\MaritalStatusRepository;
|
||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Exception;
|
||||
use Faker\Factory;
|
||||
use Faker\Generator;
|
||||
use Nelmio\Alice\Loader\NativeLoader;
|
||||
@@ -43,10 +38,6 @@ use Nelmio\Alice\ObjectSet;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
|
||||
use function count;
|
||||
use function random_int;
|
||||
use function ucfirst;
|
||||
|
||||
/**
|
||||
* Load people into database.
|
||||
*/
|
||||
@@ -118,7 +109,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
],
|
||||
],
|
||||
[
|
||||
//to have a person with same firstname as Gérard Depardieu
|
||||
// to have a person with same firstname as Gérard Depardieu
|
||||
'lastName' => 'Depardieu',
|
||||
'firstName' => 'Jean',
|
||||
'birthdate' => '1960-10-12',
|
||||
@@ -128,7 +119,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
'maritalStatus' => 'ms_divorce',
|
||||
],
|
||||
[
|
||||
//to have a person with same birthdate of Gérard Depardieu
|
||||
// to have a person with same birthdate of Gérard Depardieu
|
||||
'lastName' => 'Van Snick',
|
||||
'firstName' => 'Bart',
|
||||
'birthdate' => '1948-12-27',
|
||||
@@ -136,7 +127,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
'maritalStatus' => 'ms_legalco',
|
||||
],
|
||||
[
|
||||
//to have a woman with Depardieu as FirstName
|
||||
// to have a woman with Depardieu as FirstName
|
||||
'lastName' => 'Depardieu',
|
||||
'firstName' => 'Charline',
|
||||
'birthdate' => '1970-10-15',
|
||||
@@ -145,14 +136,14 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
'maritalStatus' => 'ms_legalco',
|
||||
],
|
||||
[
|
||||
//to have a special character in lastName
|
||||
// to have a special character in lastName
|
||||
'lastName' => 'Manço',
|
||||
'firstName' => 'Étienne',
|
||||
'center' => 'Center A',
|
||||
'maritalStatus' => 'ms_unknown',
|
||||
],
|
||||
[
|
||||
//to have true duplicate person
|
||||
// to have true duplicate person
|
||||
'lastName' => 'Depardieu',
|
||||
'firstName' => 'Jean',
|
||||
'birthdate' => '1960-10-12',
|
||||
@@ -162,7 +153,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
'maritalStatus' => 'ms_divorce',
|
||||
],
|
||||
[
|
||||
//to have false duplicate person
|
||||
// to have false duplicate person
|
||||
'lastName' => 'Depardieu',
|
||||
'firstName' => 'Jeanne',
|
||||
'birthdate' => '1966-11-13',
|
||||
@@ -253,7 +244,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
*/
|
||||
public function getRandomCenter(): Center
|
||||
{
|
||||
if (0 === count($this->cacheCenters)) {
|
||||
if (0 === \count($this->cacheCenters)) {
|
||||
$this->cacheCenters = $this->centerRepository->findAll();
|
||||
}
|
||||
|
||||
@@ -263,15 +254,15 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
/**
|
||||
* @internal This method is public and called by faker as a custom generator
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getRandomCountry(int $nullPercentage = 20): ?Country
|
||||
{
|
||||
if (0 === count($this->cacheCountries)) {
|
||||
if (0 === \count($this->cacheCountries)) {
|
||||
$this->cacheCountries = $this->countryRepository->findAll();
|
||||
}
|
||||
|
||||
if (random_int(0, 100) > $nullPercentage) {
|
||||
if (\random_int(0, 100) > $nullPercentage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -289,15 +280,15 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
/**
|
||||
* @internal This method is public and called by faker as a custom generator
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getRandomMaritalStatus(int $nullPercentage = 50): ?MaritalStatus
|
||||
{
|
||||
if (0 === count($this->cacheMaritalStatuses)) {
|
||||
if (0 === \count($this->cacheMaritalStatuses)) {
|
||||
$this->cacheMaritalStatuses = $this->maritalStatusRepository->findAll();
|
||||
}
|
||||
|
||||
if (random_int(0, 100) > $nullPercentage) {
|
||||
if (\random_int(0, 100) > $nullPercentage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -335,22 +326,22 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
/**
|
||||
* create a new person from array data.
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function addAPerson(Person $person, ObjectManager $manager)
|
||||
{
|
||||
$accompanyingPeriod = new AccompanyingPeriod(
|
||||
(new DateTime())
|
||||
(new \DateTime())
|
||||
->sub(
|
||||
new DateInterval('P' . random_int(0, 180) . 'D')
|
||||
new \DateInterval('P'.\random_int(0, 180).'D')
|
||||
)
|
||||
);
|
||||
$accompanyingPeriod->setCreatedBy($this->getRandomUser())
|
||||
->setCreatedAt(new DateTimeImmutable('now'));
|
||||
->setCreatedAt(new \DateTimeImmutable('now'));
|
||||
$person->addAccompanyingPeriod($accompanyingPeriod);
|
||||
$accompanyingPeriod->addSocialIssue($this->getRandomSocialIssue());
|
||||
|
||||
if (random_int(0, 10) > 3) {
|
||||
if (\random_int(0, 10) > 3) {
|
||||
// always add social scope:
|
||||
$accompanyingPeriod->addScope($this->getReference('scope_social'));
|
||||
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN);
|
||||
@@ -365,7 +356,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
$manager->persist($person);
|
||||
$manager->persist($accompanyingPeriod);
|
||||
|
||||
$this->addReference(self::PERSON . $person->getId(), $person);
|
||||
$this->addReference(self::PERSON.$person->getId(), $person);
|
||||
}
|
||||
|
||||
private function createAddress(): Address
|
||||
@@ -408,7 +399,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
foreach ($default as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'birthdate':
|
||||
$person->setBirthdate(new DateTime($value));
|
||||
$person->setBirthdate(new \DateTime($value));
|
||||
|
||||
break;
|
||||
|
||||
@@ -471,7 +462,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
|
||||
private function getRandomSocialIssue(): SocialIssue
|
||||
{
|
||||
if (0 === count($this->cacheSocialIssues)) {
|
||||
if (0 === \count($this->cacheSocialIssues)) {
|
||||
$this->cacheSocialIssues = $this->socialIssueRepository->findAll();
|
||||
}
|
||||
|
||||
@@ -480,7 +471,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
|
||||
|
||||
private function getRandomUser(): User
|
||||
{
|
||||
if (0 === count($this->cacheUsers)) {
|
||||
if (0 === \count($this->cacheUsers)) {
|
||||
$this->cacheUsers = $this->userRepository->findAll();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user