Conditions | 6 |
Paths | 5 |
Total Lines | 13 |
Lines | 13 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
19 | public function getUpdatedAt($format = null) |
||
20 | { |
||
21 | switch (true) { |
||
22 | case is_string($this->updated_at): |
||
23 | case is_object($this->updated_at) && get_class($this->updated_at) !== 'DateTime': |
||
24 | throw new \Exception("updated_at is not a datetime", 400); |
||
25 | case $this->updated_at === null: |
||
26 | case $format === null: |
||
27 | return $this->updated_at; |
||
28 | default: |
||
29 | return $this->updated_at->format($format); |
||
30 | } |
||
31 | } |
||
32 | |||
42 |
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.