| Conditions | 1 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 1 |
| Changes | 0 | ||
Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.
There are several approaches to avoid long parameter lists:
| 1 | <?php |
||
| 53 | 1 | public function __construct( |
|
| 54 | $hash, |
||
| 55 | $index, |
||
| 56 | $value = null, |
||
| 57 | AddressInterface $address = null, |
||
| 58 | ScriptInterface $scriptPubKey = null, |
||
| 59 | $path = null, |
||
| 60 | ScriptInterface $redeemScript = null, |
||
| 61 | ScriptInterface $witnessScript = null, |
||
| 62 | $signMode = SignInfo::MODE_SIGN |
||
| 63 | ) { |
||
| 64 | 1 | $this->hash = $hash; |
|
| 65 | 1 | $this->index = $index; |
|
| 66 | 1 | $this->value = $value; |
|
| 67 | 1 | $this->address = $address; |
|
| 68 | 1 | $this->scriptPubKey = $scriptPubKey; |
|
| 69 | 1 | $this->path = $path; |
|
| 70 | 1 | $this->redeemScript = $redeemScript; |
|
| 71 | 1 | $this->witnessScript = $witnessScript; |
|
| 72 | 1 | $this->signMode = $signMode; |
|
| 73 | 1 | } |
|
| 74 | |||
| 82 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.