Plum\Plum\Pipe\WriterPipe::createWriter PHP Method

createWriter() public static method

public static createWriter ( Plum\Plum\Writer\WriterInterface | array $element ) : WriterPipe
$element Plum\Plum\Writer\WriterInterface | array
return WriterPipe
    public static function createWriter($element)
    {
        if ($element instanceof WriterInterface) {
            $writer = $element;
        } elseif (isset($element['writer']) && $element['writer'] instanceof WriterInterface) {
            $writer = $element['writer'];
        } else {
            throw new InvalidArgumentException('Workflow::addWriter() must be called with either an instance of ' . '"Plum\\Plum\\Writer\\WriterInterface" or with an array that contains ' . '"writer".');
        }
        $pipe = new self($element);
        $pipe->writer = $writer;
        return $pipe;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param WriterInterface|array $element
  *
  * @return Workflow
  */
 public function addWriter($element)
 {
     $pipe = WriterPipe::createWriter($element);
     return $this->addPipe($pipe);
 }
All Usage Examples Of Plum\Plum\Pipe\WriterPipe::createWriter
WriterPipe