| Total Complexity | 3 |
| Total Lines | 44 |
| Duplicated Lines | 25 % |
| Coverage | 100% |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php namespace Chekote\NounStore; |
||
| 9 | class Assert |
||
| 10 | { |
||
| 11 | /** @var Store */ |
||
| 12 | protected $store; |
||
| 13 | |||
| 14 | /** @var Key */ |
||
| 15 | protected $keyService; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Assert constructor. |
||
| 19 | * |
||
| 20 | * @param Store $store the store to assert against. |
||
| 21 | * @param Key $keyService the keyService to use for key parsing/building. |
||
| 22 | * |
||
| 23 | * @codeCoverageIgnore |
||
| 24 | */ |
||
| 25 | public function __construct(Store $store, Key $keyService) |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Asserts that a value has been stored for the specified key. |
||
| 33 | * |
||
| 34 | * @param string $key The key to check. @see self::get() for formatting options. |
||
| 35 | * @param int $index [optional] The index of the key entry to check. If not specified, the |
||
| 36 | * method will ensure that at least one item is stored for the key. |
||
| 37 | * @throws OutOfBoundsException if a value has not been stored for the specified key. |
||
| 38 | * @throws InvalidArgumentException if both an $index and $key are provided, but the $key contains an nth value |
||
| 39 | * that does not match the index. |
||
| 40 | * @return mixed The value. |
||
| 41 | */ |
||
| 42 | 21 | View Code Duplication | public function keyExists($key, $index = null) |
| 55 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.