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,14 +1,21 @@
<?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\MainBundle\Templating\Entity;
use Symfony\Component\Templating\EngineInterface;
use Chill\MainBundle\Entity\Address;
use Symfony\Component\Templating\EngineInterface;
use function array_merge;
use function strtr;
class AddressRender implements ChillEntityRenderInterface
{
private EngineInterface $templating;
public const DEFAULT_OPTIONS = [
'with_valid_from' => false,
'with_valid_to' => false,
@@ -16,57 +23,59 @@ class AddressRender implements ChillEntityRenderInterface
'with_delimiter' => false,
'has_no_address' => false,
'multiline' => true,
'extended_infos' => false
'extended_infos' => false,
];
private EngineInterface $templating;
public function __construct(EngineInterface $templating)
{
$this->templating = $templating;
}
/**
* {@inheritDoc}
*/
public function supports($entity, array $options): bool
{
return $entity instanceof Address;
}
/**
* @param Address addr
*/
public function renderString($addr, array $options): string
{
$lines = [];
if (!empty($addr->getStreet())) {
$lines[0] = $addr->getStreet();
}
if (!empty($addr->getStreetNumber())) {
$lines[0] .= ", ".$addr->getStreetNumber();
}
if (!empty($addr->getPostcode())) {
$lines[1] = \strtr("{postcode} {label}", [
'{postcode}' => $addr->getPostcode()->getCode(),
'{label}' => $addr->getPostcode()->getName()
]);
}
return implode(" - ", $lines);
}
/**
* {@inheritDoc}
* @param Address addr
*/
public function renderBox($addr, array $options): string
{
$options = \array_merge(self::DEFAULT_OPTIONS, $options);
$options = array_merge(self::DEFAULT_OPTIONS, $options);
return $this->templating
->render('@ChillMain/Entity/address.html.twig', [
'address' => $addr,
'render' => $options['render'] ?? 'bloc',
'options' => $options
'options' => $options,
]);
}
/**
* @param Address addr
* @param mixed $addr
*/
public function renderString($addr, array $options): string
{
$lines = [];
if (!empty($addr->getStreet())) {
$lines[0] = $addr->getStreet();
}
if (!empty($addr->getStreetNumber())) {
$lines[0] .= ', ' . $addr->getStreetNumber();
}
if (!empty($addr->getPostcode())) {
$lines[1] = strtr('{postcode} {label}', [
'{postcode}' => $addr->getPostcode()->getCode(),
'{label}' => $addr->getPostcode()->getName(),
]);
}
return implode(' - ', $lines);
}
public function supports($entity, array $options): bool
{
return $entity instanceof Address;
}
}