Exemplo n.º 1
0
 /**
  * Encodes request into an traversable of records.
  *
  * @return Traversable|Record[]
  */
 public function toRecords()
 {
     $result = [new Record(new Header(RecordType::beginRequest(), $this->getRequestId(), 8), \pack('xCCxxxxx', $this->role->value(), 0xff & ($this->keepConnection ? 1 : 0)))];
     foreach ($this->getParameters()->encode($this->getRequestId()) as $value) {
         $result[] = $value;
     }
     while ($chunk = $this->stdin->read(65535)) {
         $result[] = new Record(new Header(RecordType::stdin(), $this->getRequestId(), strlen($chunk)), $chunk);
     }
     $result[] = new Record(new Header(RecordType::stdin(), $this->getRequestId(), 0, 0), '');
     return new ArrayIterator($result);
 }