Conditions | 8 |
Paths | 7 |
Total Lines | 22 |
Lines | 6 |
Ratio | 27.27 % |
Changes | 0 |
1 | <?php |
||
42 | public function check() : bool |
||
43 | { |
||
44 | if ($this->required == array_values($this->required)) { |
||
45 | foreach ($this->required as $key) { |
||
46 | View Code Duplication | if (!isset($this->config[$key])) { |
|
|
|||
47 | throw new InstanceCorruptException(get_class($this).':'.$key.' not set!'); |
||
48 | } |
||
49 | } |
||
50 | } else { |
||
51 | foreach ($this->required as $instance => $key) { |
||
52 | View Code Duplication | if (!isset($this->config[$key])) { |
|
53 | throw new InstanceCorruptException(get_class($this).':'.$key.' not set!'); |
||
54 | } |
||
55 | if (!is_numeric($instance)) { |
||
56 | if (!($this->config[$key] instanceof $instance)) { |
||
57 | throw new InstanceCorruptException(get_class($this).':'.$key.' not instance of '.$instance.'!'); |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | return true; |
||
63 | } |
||
64 | |||
74 |
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.