Remove unrelated code style change.

This commit is contained in:
Pol Dellaiera 2021-03-31 14:57:25 +02:00
parent 48e2d2ceab
commit 03243605da
3 changed files with 83 additions and 79 deletions

View File

@ -3,7 +3,7 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop> * <http://www.champs-libres.coop>, <info@champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -45,17 +45,17 @@ class AccompanyingPeriod
/** @var \Chill\PersonBundle\Entity\Person */ /** @var \Chill\PersonBundle\Entity\Person */
private $person; private $person;
/** @var AccompanyingPeriod\ClosingMotive */ /** @var AccompanyingPeriod\ClosingMotive */
private $closingMotive = null; private $closingMotive = null;
/** /**
* The user making the accompanying * The user making the accompanying
* *
* @var User * @var User
*/ */
private $user; private $user;
/** /**
* *
* @param \DateTime $dateOpening * @param \DateTime $dateOpening
@ -68,7 +68,7 @@ class AccompanyingPeriod
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
@ -84,7 +84,7 @@ class AccompanyingPeriod
public function setOpeningDate($openingDate) public function setOpeningDate($openingDate)
{ {
$this->openingDate = $openingDate; $this->openingDate = $openingDate;
return $this; return $this;
} }
@ -100,13 +100,17 @@ class AccompanyingPeriod
/** /**
* Set closingDate * Set closingDate
* *
* For closing a Person file, you should use Person::setClosed instead. * For closing a Person file, you should use Person::setClosed instead.
*
* @param \DateTime $dateClosing
* @return AccompanyingPeriod
*
*/ */
public function setClosingDate($closingDate) public function setClosingDate($closingDate)
{ {
$this->closingDate = $closingDate; $this->closingDate = $closingDate;
return $this; return $this;
} }
@ -119,12 +123,12 @@ class AccompanyingPeriod
{ {
return $this->closingDate; return $this->closingDate;
} }
/** /**
* *
* @return boolean * @return boolean
*/ */
public function isOpen(): bool public function isOpen(): bool
{ {
if ($this->getOpeningDate() > new \DateTime('now')) { if ($this->getOpeningDate() > new \DateTime('now')) {
return false; return false;
@ -132,9 +136,9 @@ class AccompanyingPeriod
if ($this->getClosingDate() === null) { if ($this->getClosingDate() === null) {
return true; return true;
} else {
return false;
} }
return false;
} }
/** /**
@ -148,16 +152,16 @@ class AccompanyingPeriod
if ($remark === null) { if ($remark === null) {
$remark = ''; $remark = '';
} }
$this->remark = $remark; $this->remark = $remark;
return $this; return $this;
} }
/** /**
* Get remark * Get remark
* *
* @return string * @return string
*/ */
public function getRemark() public function getRemark()
{ {
@ -166,7 +170,7 @@ class AccompanyingPeriod
/** /**
* Set person. * Set person.
* *
* For consistency, you should use Person::addAccompanyingPeriod instead. * For consistency, you should use Person::addAccompanyingPeriod instead.
* *
* @param \Chill\PersonBundle\Entity\Person $person * @param \Chill\PersonBundle\Entity\Person $person
@ -176,20 +180,20 @@ class AccompanyingPeriod
public function setPerson(\Chill\PersonBundle\Entity\Person $person = null) public function setPerson(\Chill\PersonBundle\Entity\Person $person = null)
{ {
$this->person = $person; $this->person = $person;
return $this; return $this;
} }
/** /**
* Get person * Get person
* *
* @return \Chill\PersonBundle\Entity\Person * @return \Chill\PersonBundle\Entity\Person
*/ */
public function getPerson() public function getPerson()
{ {
return $this->person; return $this->person;
} }
public function getClosingMotive() public function getClosingMotive()
{ {
return $this->closingMotive; return $this->closingMotive;
@ -200,13 +204,13 @@ class AccompanyingPeriod
$this->closingMotive = $closingMotive; $this->closingMotive = $closingMotive;
return $this; return $this;
} }
/** /**
* If the period can be reopened. * If the period can be reopened.
* *
* This function test if the period is closed and if the period is the last * This function test if the period is closed and if the period is the last
* for the associated person * for the associated person
* *
* @return boolean * @return boolean
*/ */
public function canBeReOpened() public function canBeReOpened()
@ -214,12 +218,12 @@ class AccompanyingPeriod
if ($this->isOpen() === true) { if ($this->isOpen() === true) {
return false; return false;
} }
$periods = $this->getPerson()->getAccompanyingPeriodsOrdered(); $periods = $this->getPerson()->getAccompanyingPeriodsOrdered();
return end($periods) === $this; return end($periods) === $this;
} }
public function reOpen() public function reOpen()
{ {
$this->setClosingDate(null); $this->setClosingDate(null);
@ -231,29 +235,29 @@ class AccompanyingPeriod
if ($this->isOpen()) { if ($this->isOpen()) {
return; return;
} }
if (! $this->isClosingAfterOpening()) { if (! $this->isClosingAfterOpening()) {
$context->buildViolation('The date of closing is before the date of opening') $context->buildViolation('The date of closing is before the date of opening')
->atPath('dateClosing') ->atPath('dateClosing')
->addViolation(); ->addViolation();
} }
} }
/** /**
* Returns true if the closing date is after the opening date. * Returns true if the closing date is after the opening date.
* *
* @return boolean * @return boolean
*/ */
public function isClosingAfterOpening() { public function isClosingAfterOpening() {
$diff = $this->getOpeningDate()->diff($this->getClosingDate()); $diff = $this->getOpeningDate()->diff($this->getClosingDate());
if ($diff->invert === 0) { if ($diff->invert === 0) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
function getUser(): ?User function getUser(): ?User
{ {
return $this->user; return $this->user;
@ -262,7 +266,7 @@ class AccompanyingPeriod
function setUser(User $user): self function setUser(User $user): self
{ {
$this->user = $user; $this->user = $user;
return $this; return $this;
} }

View File

@ -44,7 +44,7 @@ class Person implements HasCenterInterface {
/** @var string The person's last name */ /** @var string The person's last name */
private $lastName; private $lastName;
/** /**
* *
* @var \Doctrine\Common\Collections\Collection * @var \Doctrine\Common\Collections\Collection
@ -121,12 +121,12 @@ class Person implements HasCenterInterface {
* @var \Doctrine\Common\Collections\Collection * @var \Doctrine\Common\Collections\Collection
*/ */
private $addresses; private $addresses;
/** /**
* @var string * @var string
*/ */
private $fullnameCanonical; private $fullnameCanonical;
public function __construct(\DateTime $opening = null) { public function __construct(\DateTime $opening = null) {
$this->accompanyingPeriods = new ArrayCollection(); $this->accompanyingPeriods = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection(); $this->spokenLanguages = new ArrayCollection();
@ -333,7 +333,7 @@ class Person implements HasCenterInterface {
{ {
return $this->lastName; return $this->lastName;
} }
public function getAltNames(): \Doctrine\Common\Collections\Collection public function getAltNames(): \Doctrine\Common\Collections\Collection
{ {
return $this->altNames; return $this->altNames;
@ -342,7 +342,7 @@ class Person implements HasCenterInterface {
public function setAltNames(\Doctrine\Common\Collections\Collection $altNames) public function setAltNames(\Doctrine\Common\Collections\Collection $altNames)
{ {
$this->altNames = $altNames; $this->altNames = $altNames;
return $this; return $this;
} }
@ -352,20 +352,20 @@ class Person implements HasCenterInterface {
$this->altNames->add($altName); $this->altNames->add($altName);
$altName->setPerson($this); $altName->setPerson($this);
} }
return $this; return $this;
} }
public function removeAltName(PersonAltName $altName) public function removeAltName(PersonAltName $altName)
{ {
if ($this->altNames->contains($altName)) { if ($this->altNames->contains($altName)) {
$altName->setPerson(null); $altName->setPerson(null);
$this->altNames->removeElement($altName); $this->altNames->removeElement($altName);
} }
return $this; return $this;
} }
/** /**
* Set birthdate * Set birthdate
* *

View File

@ -2,8 +2,8 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop> * <http://www.champs-libres.coop>, <info@champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -35,55 +35,55 @@ use Generator;
class PersonTest extends \PHPUnit\Framework\TestCase class PersonTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* Test the creation of an accompanying, its closure and the access to * Test the creation of an accompanying, its closure and the access to
* the current accompaniying period via the getCurrentAccompanyingPeriod * the current accompaniying period via the getCurrentAccompanyingPeriod
* function. * function.
*/ */
public function testGetCurrentAccompanyingPeriod() public function testGetCurrentAccompanyingPeriod()
{ {
$d = new \DateTime('yesterday'); $d = new \DateTime('yesterday');
$p = new Person($d); $p = new Person($d);
$period = $p->getCurrentAccompanyingPeriod(); $period = $p->getCurrentAccompanyingPeriod();
$this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period); $this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period);
$this->assertTrue($period->isOpen()); $this->assertTrue($period->isOpen());
$this->assertEquals($d, $period->getOpeningDate()); $this->assertEquals($d, $period->getOpeningDate());
//close and test //close and test
$period->setClosingDate(new \DateTime('tomorrow')); $period->setClosingDate(new \DateTime('tomorrow'));
$shouldBeNull = $p->getCurrentAccompanyingPeriod(); $shouldBeNull = $p->getCurrentAccompanyingPeriod();
$this->assertNull($shouldBeNull); $this->assertNull($shouldBeNull);
} }
/** /**
* Test if the getAccompanyingPeriodsOrdered function return a list of * Test if the getAccompanyingPeriodsOrdered function return a list of
* periods ordered ascendency. * periods ordered ascendency.
*/ */
public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod() public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
{ {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person($d);
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period); $p->close($period);
$f = new \DateTime("2013/1/1"); $f = new \DateTime("2013/1/1");
$p->open(new AccompanyingPeriod($f)); $p->open(new AccompanyingPeriod($f));
$g = new \DateTime("2013/4/1"); $g = new \DateTime("2013/4/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
$p->close($period); $p->close($period);
$r = $p->getAccompanyingPeriodsOrdered(); $r = $p->getAccompanyingPeriodsOrdered();
$date = $r[0]->getOpeningDate()->format('Y-m-d'); $date = $r[0]->getOpeningDate()->format('Y-m-d');
$this->assertEquals($date, '2013-01-01'); $this->assertEquals($date, '2013-01-01');
} }
/** /**
* Test if the getAccompanyingPeriodsOrdered function, for periods * Test if the getAccompanyingPeriodsOrdered function, for periods
* starting at the same time order regarding to the closing date. * starting at the same time order regarding to the closing date.
@ -91,25 +91,25 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testAccompanyingPeriodOrderSameDateOpening() { public function testAccompanyingPeriodOrderSameDateOpening() {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person($d);
$g = new \DateTime("2013/4/1"); $g = new \DateTime("2013/4/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
$p->close($period); $p->close($period);
$f = new \DateTime("2013/2/1"); $f = new \DateTime("2013/2/1");
$p->open(new AccompanyingPeriod($f)); $p->open(new AccompanyingPeriod($f));
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period); $p->close($period);
$r = $p->getAccompanyingPeriodsOrdered(); $r = $p->getAccompanyingPeriodsOrdered();
$date = $r[0]->getClosingDate()->format('Y-m-d'); $date = $r[0]->getClosingDate()->format('Y-m-d');
$this->assertEquals($date, '2013-03-01'); $this->assertEquals($date, '2013-03-01');
} }
/** /**
* Test if the function checkAccompanyingPeriodIsNotCovering returns * Test if the function checkAccompanyingPeriodIsNotCovering returns
* the good constant when two periods are collapsing : a period * the good constant when two periods are collapsing : a period
@ -118,23 +118,23 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testDateCoveringWithCoveringAccompanyingPeriod() { public function testDateCoveringWithCoveringAccompanyingPeriod() {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person($d);
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period); $p->close($period);
$f = new \DateTime("2013/1/1"); $f = new \DateTime("2013/1/1");
$p->open(new AccompanyingPeriod($f)); $p->open(new AccompanyingPeriod($f));
$g = new \DateTime("2013/4/1"); $g = new \DateTime("2013/4/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
$p->close($period); $p->close($period);
$r = $p->checkAccompanyingPeriodsAreNotCollapsing(); $r = $p->checkAccompanyingPeriodsAreNotCollapsing();
$this->assertEquals($r['result'], Person::ERROR_PERIODS_ARE_COLLAPSING); $this->assertEquals($r['result'], Person::ERROR_PERIODS_ARE_COLLAPSING);
} }
/** /**
* Test if the function checkAccompanyingPeriodIsNotCovering returns * Test if the function checkAccompanyingPeriodIsNotCovering returns
* the good constant when two periods are collapsing : a period is open * the good constant when two periods are collapsing : a period is open
@ -143,16 +143,16 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testNotOpenAFileReOpenedLater() { public function testNotOpenAFileReOpenedLater() {
$d = new \DateTime("2013/2/1"); $d = new \DateTime("2013/2/1");
$p = new Person($d); $p = new Person($d);
$e = new \DateTime("2013/3/1"); $e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period); $p->close($period);
$f = new \DateTime("2013/1/1"); $f = new \DateTime("2013/1/1");
$p->open(new AccompanyingPeriod($f)); $p->open(new AccompanyingPeriod($f));
$r = $p->checkAccompanyingPeriodsAreNotCollapsing(); $r = $p->checkAccompanyingPeriodsAreNotCollapsing();
$this->assertEquals($r['result'], Person::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD); $this->assertEquals($r['result'], Person::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD);
} }