| Conditions | 9 |
| Paths | 9 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 90 |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 22 | public function __construct(Math $math, Flags $flags, Buffer $vch, $size = 4) |
||
| 23 | { |
||
| 24 | if (!is_numeric($size)) { |
||
| 25 | throw new \RuntimeException('ScriptNum size must be numeric'); |
||
| 26 | } |
||
| 27 | |||
| 28 | $bufferSize = $vch->getSize(); |
||
| 29 | if ($bufferSize > $size) { |
||
| 30 | throw new ScriptStackException('a'.InterpreterInterface::VERIFY_MINIMALDATA);//, 'Script number overflow'); |
||
| 31 | } |
||
| 32 | |||
| 33 | $str = $vch->getBinary(); |
||
| 34 | if ($flags->checkFlags(InterpreterInterface::VERIFY_MINIMALDATA) && $bufferSize > 0) { |
||
| 35 | if ((ord($str[0]) & 0x7f) === 0) { |
||
| 36 | if ($bufferSize <= 1 || (ord($str[1]) & 0x7f) === 0) { |
||
| 37 | throw new ScriptStackException('b'.InterpreterInterface::VERIFY_MINIMALDATA);//, 'Non-minimally encoded integer'); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($bufferSize === 0) { |
||
| 43 | $str = "\x00"; |
||
| 44 | } |
||
| 45 | |||
| 46 | $this->math = $math; |
||
| 47 | parent::__construct($str, $size, $math); |
||
| 48 | } |
||
| 49 | |||
| 58 |