Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | 8 | public function __construct(ScriptInterface $script, Opcodes $opcodes = null) |
|
27 | { |
||
28 | 8 | if ($script instanceof self) { |
|
29 | 2 | throw new WitnessScriptException("Cannot nest V0 P2WSH scripts."); |
|
30 | 6 | } else if ($script instanceof P2shScript) { |
|
31 | 2 | throw new WitnessScriptException("Cannot embed a P2SH script in a V2 P2WSH script."); |
|
32 | } |
||
33 | |||
34 | 4 | parent::__construct($script->getBuffer(), $opcodes); |
|
35 | |||
36 | 4 | $this->witnessScriptHash = $script->getWitnessScriptHash(); |
|
37 | 4 | $this->outputScript = ScriptFactory::scriptPubKey()->p2wsh($this->witnessScriptHash); |
|
38 | 4 | } |
|
39 | |||
60 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: