Exemplo n.º 1
0
 /**
  * @param array $hash
  * @return int
  */
 public function write(array $hash)
 {
     $frame = $this->encoder->toCompressedFrame($hash, $this->nextSequence());
     if ($this->unackedSequenceSize() >= $this->windowSize) {
         $this->ack();
     }
     return $this->socket->write($frame);
 }
Exemplo n.º 2
0
 public function testWrite()
 {
     $testData = array('a' => 'b');
     $encodedData = json_encode($testData);
     $dataLength = strlen($encodedData);
     $this->encoder->expects($this->once())->method('toCompressedFrame')->with($this->equalTo($testData), $this->equalTo(1))->willReturn($encodedData);
     $this->socket->expects($this->once())->method('write')->with($this->equalTo($encodedData))->willReturn($dataLength);
     $actual = $this->instance->write($testData);
     $this->assertEquals($dataLength, $actual);
 }
Exemplo n.º 3
0
 /**
  * @param array $data
  * @param string $lang
  */
 function export(array $data, $lang)
 {
     foreach ($data as $sheet => $array) {
         if ($sheet == 'sitem') {
             $sheet = 'item';
         }
         $ext = $this->encoder->name();
         $filename = "{$this->path}/words_{$lang}_{$sheet}.{$ext}";
         file_put_contents($filename, $this->encoder->encode($array));
     }
 }
Exemplo n.º 4
0
 /**
  * Turn an object graph into a string
  *
  * @param mixed $value
  * @return string
  */
 public function serialize($value)
 {
     $this->navigator->accept($this->navigator, $this->visitor, $value);
     $result = $this->visitor->getResult();
     return $this->encoder->encode($result);
 }
Exemplo n.º 5
0
 /**
  * {@inheritDoc}
  */
 public function encode($value)
 {
     return $this->encoder->encode($value);
 }
Exemplo n.º 6
0
 /**
  * Verify if the $password matches the $hash.
  *
  * @param string $password
  * @param string $hash
  *
  * @return bool True if $password matches $hash. Otherwise false is returned.
  */
 public function verifyPasswordHash($password, $hash)
 {
     return $this->encoderProviderInstance->verifyPasswordHash($password, $hash);
 }