mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,61 +1,54 @@
|
||||
<?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\Config;
|
||||
|
||||
|
||||
/**
|
||||
* Give help to interact with the config for alt names
|
||||
*
|
||||
*
|
||||
* Give help to interact with the config for alt names.
|
||||
*/
|
||||
class ConfigPersonAltNamesHelper
|
||||
{
|
||||
/**
|
||||
* the raw config, directly from the container parameter
|
||||
* the raw config, directly from the container parameter.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $config = [];
|
||||
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if at least one alt name is configured
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAltNames(): bool
|
||||
{
|
||||
return count($this->config) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the choices as key => values
|
||||
*
|
||||
* @return array
|
||||
* get the choices as key => values.
|
||||
*/
|
||||
public function getChoices(): array
|
||||
{
|
||||
$choices = [];
|
||||
|
||||
foreach ($this->config as $entry) {
|
||||
|
||||
$labels = $entry['labels'];
|
||||
$lang = false;
|
||||
$label = false;
|
||||
$cur = reset($labels);
|
||||
|
||||
while ($cur) {
|
||||
if (key($labels) === 'lang') {
|
||||
$lang = current($labels);
|
||||
}
|
||||
|
||||
|
||||
if (key($labels) === 'label') {
|
||||
$label = current($labels);
|
||||
}
|
||||
|
||||
if ($lang !== FALSE && $label !== FALSE) {
|
||||
|
||||
if (false !== $lang && false !== $label) {
|
||||
$choices[$entry['key']][$lang] = $label;
|
||||
$lang = false;
|
||||
$label = false;
|
||||
@@ -63,8 +56,15 @@ class ConfigPersonAltNamesHelper
|
||||
$cur = next($labels);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if at least one alt name is configured.
|
||||
*/
|
||||
public function hasAltNames(): bool
|
||||
{
|
||||
return count($this->config) > 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user