| Conditions | 9 |
| Paths | 256 |
| Total Lines | 30 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 11.107 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | 1 | public function toJson() |
|
| 36 | { |
||
| 37 | 1 | $json = []; |
|
| 38 | 1 | if ($this->registrationIds) { |
|
|
|
|||
| 39 | 1 | $json['registration_ids'] = $this->registrationIds; |
|
| 40 | 1 | } |
|
| 41 | 1 | if ($this->collapseKey) { |
|
| 42 | 1 | $json['collapse_key'] = $this->collapseKey; |
|
| 43 | 1 | } |
|
| 44 | 1 | if ($this->data) { |
|
| 45 | 1 | $json['data'] = $this->data; |
|
| 46 | 1 | } |
|
| 47 | 1 | if ($this->notification) { |
|
| 48 | 1 | $json['notification'] = $this->notification; |
|
| 49 | 1 | } |
|
| 50 | 1 | if ($this->delayWhileIdle) { |
|
| 51 | $json['delay_while_idle'] = $this->delayWhileIdle; |
||
| 52 | } |
||
| 53 | 1 | if ($this->timeToLive != 2419200) { |
|
| 54 | $json['time_to_live'] = $this->timeToLive; |
||
| 55 | } |
||
| 56 | 1 | if ($this->restrictedPackageName) { |
|
| 57 | $json['restricted_package_name'] = $this->restrictedPackageName; |
||
| 58 | } |
||
| 59 | 1 | if ($this->dryRun) { |
|
| 60 | $json['dry_run'] = $this->dryRun; |
||
| 61 | } |
||
| 62 | |||
| 63 | 1 | return Json::encode($json); |
|
| 64 | } |
||
| 65 | } |
||
| 66 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.