Author: Florian Eckerstorfer
Inheritance: extends AbstractPipe
コード例 #1
0
ファイル: Workflow.php プロジェクト: plumphp/plum
 /**
  * Writes the given item to the given writer if the no filter is given or the filter returns `true`.
  *
  * @param mixed      $item
  * @param WriterPipe $pipe
  *
  * @return bool `true` if the item has been written, `false` if not.
  */
 protected function writeItem($item, WriterPipe $pipe)
 {
     if ($pipe->getFilter() === null || $pipe->getFilter()->filter($item) === true) {
         $pipe->getWriter()->writeItem($item);
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: WriterPipeTest.php プロジェクト: plumphp/plum
 /**
  * @test
  * @covers Plum\Plum\Pipe\WriterPipe::createWriter()
  * @covers Plum\Plum\Pipe\WriterPipe::__construct()
  * @covers Plum\Plum\Pipe\WriterPipe::getFilter()
  */
 public function createWriterTakesCallbackFilter()
 {
     /** @var \Plum\Plum\Writer\WriterInterface $writer */
     $writer = Mockery::mock('\\Plum\\Plum\\Writer\\WriterInterface');
     $filter = function ($v) {
         return true;
     };
     $pipe = WriterPipe::createWriter(['writer' => $writer, 'filter' => $filter]);
     $this->assertInstanceOf('\\Plum\\Plum\\Pipe\\WriterPipe', $pipe);
     $this->assertInstanceOf('\\Plum\\Plum\\Filter\\FilterInterface', $pipe->getFilter());
 }