Issues (13)

src/Method/Traits/FillFromArrayTrait.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method\Traits;
6
7
use Greenplugin\TelegramBot\Exception\BadArgumentException;
8
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
9
10
/**
11
 * Trait FillFromArrayTrait.
12
 */
13
trait FillFromArrayTrait
14
{
15
    /**
16
     * @param array                       $data
17
     * @param array|null                  $exclude
18
     * @param NameConverterInterface|null $converter
19
     *
20
     * @throws BadArgumentException
21
     */
22 2
    private function fill(array $data, array $exclude = null, NameConverterInterface $converter = null)
0 ignored issues
show
The parameter $exclude is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    private function fill(array $data, /** @scrutinizer ignore-unused */ array $exclude = null, NameConverterInterface $converter = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24 2
        foreach ($data as $key => $value) {
25 2
            if ($converter) {
26
                $key = $converter->denormalize($key);
27
            }
28 2
            if (!\property_exists($this, $key)) {
29
                throw new BadArgumentException(\sprintf('Argument %s not found in %s', $key, self::class));
30
            }
31 2
            $this->{$key} = $value;
32
        }
33 2
    }
34
}
35