Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | public function by(callable $func, $format = null) |
||
32 | { |
||
33 | $ret = parent::by($func); |
||
34 | |||
35 | if (! is_null($format)) { |
||
36 | foreach ($this->containerCollection->getAll() as $container) { |
||
|
|||
37 | $rawData = $container->dump(); |
||
38 | $formattedDatetime = Carbon::parse($rawData[$this->targetKey])->format($format); |
||
39 | $container->with([$this->targetKey => $formattedDatetime]); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | return $ret; |
||
44 | } |
||
45 | } |
||
46 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: