| Conditions | 2 |
| Paths | 2 |
| Total Lines | 26 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 32 | public function generate($url = '', User $user = null) |
||
| 33 | { |
||
| 34 | $hash = $this->generateUniqueHash(); |
||
| 35 | $data = [ |
||
| 36 | 'url' => $url, |
||
| 37 | 'hash' => $hash, |
||
| 38 | ]; |
||
| 39 | |||
| 40 | /* |
||
| 41 | * If the user_id has been offered |
||
| 42 | * add the user_id so we can build |
||
| 43 | * a relationship between link and |
||
| 44 | * user. |
||
| 45 | */ |
||
| 46 | if ($user) { |
||
| 47 | $data['user_id'] = $user->id; |
||
|
|
|||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Finally insert the link into |
||
| 52 | * the database. |
||
| 53 | */ |
||
| 54 | $link = self::create($data); |
||
| 55 | |||
| 56 | return $link; |
||
| 57 | } |
||
| 58 | |||
| 95 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.