Greenplugin /
telegram-bot-api
| 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
|
|||
| 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 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.