cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,46 +1,38 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AMLI\BudgetBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* AbstractElement
* AbstractElement.
*
* @ORM\MappedSuperclass()
* @ORM\MappedSuperclass
*/
abstract class AbstractElement
{
/**
*
* @var Person
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*/
private $person;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=255)
*/
private $type;
/**
* @var decimal
*
* @ORM\Column(name="amount", type="decimal", precision=10, scale=2)
* @Assert\GreaterThan(
* value=0
* value=0
* )
* @Assert\NotNull(
* message="The amount cannot be empty"
* message="The amount cannot be empty"
* )
*
*/
private $amount;
@@ -52,52 +44,82 @@ abstract class AbstractElement
private $comment;
/**
* @var \DateTimeImmutable
* @var DateTimeImmutable|null
*
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="The budget element's end date must be after the start date"
* )
*/
private $endDate;
/**
* @var Person
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*/
private $person;
/**
* @var DateTimeImmutable
*
* @ORM\Column(name="startDate", type="datetime_immutable")
* @Assert\Date()
* @Assert\Date
*/
private $startDate;
/**
* @var \DateTimeImmutable|null
* @var string
*
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="The budget element's end date must be after the start date"
* )
* @ORM\Column(name="type", type="string", length=255)
*/
private $endDate;
abstract public function isCharge(): bool;
abstract public function isResource(): bool;
private $type;
/**
* Get amount.
*
* @return float
*/
public function getAmount()
{
return (float) $this->amount;
}
/**
* Get comment.
*
* @return string|null
*/
public function getComment()
{
return $this->comment;
}
/**
* Get endDate.
*
* @return DateTimeImmutable|null
*/
public function getEndDate()
{
return $this->endDate;
}
public function getPerson(): Person
{
return $this->person;
}
public function setPerson(Person $person)
{
$this->person = $person;
return $this;
}
/**
* Set type.
* Get startDate.
*
* @param string $type
*
* @return AbstractElement
* @return DateTimeImmutable
*/
public function setType($type)
public function getStartDate()
{
$this->type = $type;
return $this;
return $this->startDate;
}
/**
@@ -110,6 +132,15 @@ abstract class AbstractElement
return $this->type;
}
abstract public function isCharge(): bool;
public function isEmpty()
{
return 0 == $this->amount;
}
abstract public function isResource(): bool;
/**
* Set amount.
*
@@ -124,16 +155,6 @@ abstract class AbstractElement
return $this;
}
/**
* Get amount.
*
* @return double
*/
public function getAmount()
{
return (double) $this->amount;
}
/**
* Set comment.
*
@@ -149,27 +170,40 @@ abstract class AbstractElement
}
/**
* Get comment.
* Set endDate.
*
* @return string|null
* @return AbstractElement
*/
public function getComment()
public function setEndDate(?DateTimeInterface $endDate = null)
{
return $this->comment;
if ($endDate instanceof DateTime) {
$this->endDate = DateTimeImmutable::createFromMutable($endDate);
} elseif (null === $endDate) {
$this->endDate = null;
} else {
$this->endDate = $endDate;
}
return $this;
}
public function setPerson(Person $person)
{
$this->person = $person;
return $this;
}
/**
* Set startDate.
*
* @param \DateTimeInterface $startDate
*
* @return AbstractElement
*/
public function setStartDate(\DateTimeInterface $startDate)
public function setStartDate(DateTimeInterface $startDate)
{
if ($startDate instanceof \DateTime) {
$this->startDate = \DateTimeImmutable::createFromMutable($startDate);
} elseif (NULL === $startDate) {
if ($startDate instanceof DateTime) {
$this->startDate = DateTimeImmutable::createFromMutable($startDate);
} elseif (null === $startDate) {
$this->startDate = null;
} else {
$this->startDate = $startDate;
@@ -179,47 +213,16 @@ abstract class AbstractElement
}
/**
* Get startDate.
* Set type.
*
* @return \DateTimeImmutable
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set endDate.
*
* @param \DateTimeInterface|null $endDate
* @param string $type
*
* @return AbstractElement
*/
public function setEndDate(\DateTimeInterface $endDate = null)
public function setType($type)
{
if ($endDate instanceof \DateTime) {
$this->endDate = \DateTimeImmutable::createFromMutable($endDate);
} elseif (NULL === $endDate) {
$this->endDate = null;
} else {
$this->endDate = $endDate;
}
$this->type = $type;
return $this;
}
/**
* Get endDate.
*
* @return \DateTimeImmutable|null
*/
public function getEndDate()
{
return $this->endDate;
}
public function isEmpty()
{
return $this->amount == 0;
}
}