| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function getChangedValues(): Collection |
||
| 34 | { |
||
| 35 | |||
| 36 | if (!isset($this->logChangesOnAttributes)) { |
||
| 37 | return collect(); |
||
| 38 | } |
||
| 39 | |||
| 40 | return collect($this->getChangedAttributeNames()) |
||
| 41 | ->filter(function (string $attributeName) { |
||
| 42 | return collect($this->logChangesOnAttributes)->contains($attributeName); |
||
|
|
|||
| 43 | }) |
||
| 44 | ->map(function (string $changedAttributeName) { |
||
| 45 | return [ |
||
| 46 | 'old' => $this->oldValues[$changedAttributeName], |
||
| 47 | 'new' => $this->newValues[$changedAttributeName], |
||
| 48 | ]; |
||
| 49 | }); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
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: