| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 77 | public function setImageFile(File $file = null) |
||
| 78 | { |
||
| 79 | $this->imageFile = $file; |
||
| 80 | |||
| 81 | if ($file) { |
||
| 82 | // It is required that at least one field changes if you are using doctrine |
||
| 83 | // otherwise the event listeners won't be called and the file is lost |
||
| 84 | $this->updatedAt = new \DateTime(); |
||
|
|
|||
| 85 | } |
||
| 86 | |||
| 87 | return $this; |
||
| 88 | } |
||
| 89 | } |
||
| 90 |
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: