Пример #1
0
 /**
  * Sets bits from a binary string
  * @param string $str
  * @throws \InvalidArgumentException
  */
 protected function fromBinaryString($str)
 {
     if (!(\is_string($str) && \preg_match('/^[01]+$/', $str))) {
         throw new \InvalidArgumentException('$str is not a binary string');
     }
     for ($i = 0, $l = \strlen($str); $i < $l; ++$i) {
         $this->_List->pushFront($str[$i] === '1' ? true : false);
     }
 }
Пример #2
0
 public function testPushFront()
 {
     $this->_List->pushFront('John', 'Paul', 'George', 'Ringo');
     $this->assertEquals('John', $this->_List->front());
 }