mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 04:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,47 @@
|
||||
<?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\MainBundle\Entity\HasCenterInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Charge
|
||||
* Charge.
|
||||
*
|
||||
* @ORM\Table(name="chill_budget.charge")
|
||||
* @ORM\Entity(repositoryClass="Chill\AMLI\BudgetBundle\Repository\ChargeRepository")
|
||||
*/
|
||||
class Charge extends AbstractElement implements HasCenterInterface
|
||||
{
|
||||
public const HELP_ASKED = 'running';
|
||||
|
||||
public const HELP_NO = 'no';
|
||||
|
||||
public const HELP_NOT_RELEVANT = 'not-relevant';
|
||||
|
||||
public const HELP_YES = 'yes';
|
||||
|
||||
public const HELPS = [
|
||||
self::HELP_ASKED,
|
||||
self::HELP_NO,
|
||||
self::HELP_YES,
|
||||
self::HELP_NOT_RELEVANT,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(name="help", type="string", nullable=true)
|
||||
*/
|
||||
private $help = self::HELP_NOT_RELEVANT;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
@@ -21,30 +50,20 @@ class Charge extends AbstractElement implements HasCenterInterface
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @ORM\Column(name="help", type="string", nullable=true)
|
||||
*/
|
||||
private $help = self::HELP_NOT_RELEVANT;
|
||||
|
||||
const HELP_ASKED = 'running';
|
||||
const HELP_NO = 'no';
|
||||
const HELP_YES = 'yes';
|
||||
const HELP_NOT_RELEVANT = 'not-relevant';
|
||||
|
||||
const HELPS = [
|
||||
self::HELP_ASKED,
|
||||
self::HELP_NO,
|
||||
self::HELP_YES,
|
||||
self::HELP_NOT_RELEVANT
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setStartDate(new \DateTimeImmutable('today'));
|
||||
$this->setStartDate(new DateTimeImmutable('today'));
|
||||
}
|
||||
|
||||
public function getCenter(): \Chill\MainBundle\Entity\Center
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
|
||||
public function getHelp()
|
||||
{
|
||||
return $this->help;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,23 +75,6 @@ class Charge extends AbstractElement implements HasCenterInterface
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getHelp()
|
||||
{
|
||||
return $this->help;
|
||||
}
|
||||
|
||||
public function setHelp($help)
|
||||
{
|
||||
$this->help = $help;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCenter(): \Chill\MainBundle\Entity\Center
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
|
||||
public function isCharge(): bool
|
||||
{
|
||||
@@ -83,4 +85,11 @@ class Charge extends AbstractElement implements HasCenterInterface
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setHelp($help)
|
||||
{
|
||||
$this->help = $help;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,20 @@
|
||||
<?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\MainBundle\Entity\HasCenterInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Resource
|
||||
* Resource.
|
||||
*
|
||||
* @ORM\Table(name="chill_budget.resource")
|
||||
* @ORM\Entity(repositoryClass="Chill\AMLI\BudgetBundle\Repository\ResourceRepository")
|
||||
@@ -21,13 +29,17 @@ class Resource extends AbstractElement implements HasCenterInterface
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setStartDate(new \DateTimeImmutable('today'));
|
||||
$this->setStartDate(new DateTimeImmutable('today'));
|
||||
}
|
||||
|
||||
public function getCenter(): \Chill\MainBundle\Entity\Center
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
@@ -38,11 +50,6 @@ class Resource extends AbstractElement implements HasCenterInterface
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCenter(): \Chill\MainBundle\Entity\Center
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
}
|
||||
|
||||
public function isCharge(): bool
|
||||
{
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user