Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 14 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
16 | public function __construct(array $values) |
||
17 | { |
||
18 | if (!isset($values['value'])) { |
||
19 | throw new \RuntimeException('Title callback must be specified.'); |
||
20 | } |
||
21 | |||
22 | $titleCallback = $values['value']; |
||
23 | |||
24 | if (!is_callable($titleCallback)) { |
||
25 | throw new \RuntimeException('Title callback must be callable.'); |
||
26 | } |
||
27 | |||
28 | parent::__construct(['_title_callback' => $titleCallback]); |
||
29 | } |
||
30 | } |
||
31 |
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.