/** * @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); }
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); }
/** * @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)); } }
/** * 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); }
/** * {@inheritDoc} */ public function encode($value) { return $this->encoder->encode($value); }
/** * 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); }