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,23 +1,32 @@
<?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\PersonBundle\Templating\Entity;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use RuntimeException;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Component\Templating\EngineInterface;
use function array_reverse;
use function implode;
final class SocialIssueRender implements ChillEntityRenderInterface
{
private TranslatableStringHelper $translatableStringHelper;
private EngineInterface $engine;
public const DEFAULT_ARGS = [
self::SEPARATOR_KEY => ' > ',
];
public const SEPARATOR_KEY = 'default.separator';
public const DEFAULT_ARGS = [
self::SEPARATOR_KEY => ' > ',
];
private EngineInterface $engine;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
{
@@ -25,49 +34,9 @@ final class SocialIssueRender implements ChillEntityRenderInterface
$this->engine = $engine;
}
public function supports($entity, array $options): bool
{
return $entity instanceof SocialIssue;
}
/**
* @param SocialIssue $socialIssue
*/
public function renderString($socialIssue, array $options): string
{
/** @var $socialIssue SocialIssue */
$options = array_merge(self::DEFAULT_ARGS, $options);
$titles = [$this->translatableStringHelper->localize($socialIssue->getTitle())];
// loop to parent, until root
while ($socialIssue->hasParent()) {
$socialIssue = $socialIssue->getParent();
$titles[] = $this->translatableStringHelper->localize(
$socialIssue->getTitle()
);
}
$titles = \array_reverse($titles);
return \implode($options[self::SEPARATOR_KEY], $titles);
}
protected function buildParents(SocialIssue $socialIssue): array
{
$parents = [];
while ($socialIssue->hasParent()) {
$socialIssue = $parents[] = $socialIssue->getParent();
}
return $parents;
}
/**
*
* @param SocialIssue $socialIssue
*/
public function renderBox($socialIssue, array $options): string
{
$options = array_merge(self::DEFAULT_ARGS, $options);
@@ -81,8 +50,47 @@ final class SocialIssueRender implements ChillEntityRenderInterface
[
'socialIssue' => $socialIssue,
'parents' => $parents,
'options' => $options
'options' => $options,
]
);
}
/**
* @param SocialIssue $socialIssue
*/
public function renderString($socialIssue, array $options): string
{
/** @var SocialIssue $socialIssue */
$options = array_merge(self::DEFAULT_ARGS, $options);
$titles = [$this->translatableStringHelper->localize($socialIssue->getTitle())];
// loop to parent, until root
while ($socialIssue->hasParent()) {
$socialIssue = $socialIssue->getParent();
$titles[] = $this->translatableStringHelper->localize(
$socialIssue->getTitle()
);
}
$titles = array_reverse($titles);
return implode($options[self::SEPARATOR_KEY], $titles);
}
public function supports($entity, array $options): bool
{
return $entity instanceof SocialIssue;
}
private function buildParents(SocialIssue $socialIssue): array
{
$parents = [];
while ($socialIssue->hasParent()) {
$socialIssue = $parents[] = $socialIssue->getParent();
}
return $parents;
}
}