예제 #1
0
파일: Workflow.php 프로젝트: cocur/plum
 /**
  * @param mixed  $item
  * @param Result $result
  *
  * @return void
  */
 protected function processItem($item, Result $result)
 {
     $written = false;
     foreach ($this->pipeline as $element) {
         if ($element[0] === self::PIPELINE_TYPE_FILTER) {
             if ($element[1]->filter($item) === false) {
                 return;
             }
         } else {
             if ($element[0] === self::PIPELINE_TYPE_CONVERTER) {
                 $item = $this->convertItem($item, $element[1], $element[2]);
             } else {
                 if ($element[0] === self::PIPELINE_TYPE_WRITER) {
                     if ($this->writeItem($item, $element[1], $element[2]) === true) {
                         $result->incWriteCount();
                         $written = true;
                     }
                 }
             }
         }
     }
     if ($written === true) {
         $result->incItemWriteCount();
     }
 }
예제 #2
0
파일: ResultTest.php 프로젝트: cocur/plum
 /**
  * @test
  * @covers Cocur\Plum\Result::incWriteCount()
  * @covers Cocur\Plum\Result::getWriteCount()
  */
 public function incWriteCountShouldIncreaseWriteCount()
 {
     $this->result->incWriteCount();
     $this->assertEquals(1, $this->result->getWriteCount());
 }