PHP Classes

File: example/InputArray/run.php

Recommend this page to a friend!
  Classes of nvb  >  PHP Queue Jobs Piping  >  example/InputArray/run.php  >  Download  
File: example/InputArray/run.php
Role: Example script
Content type: text/plain
Description: Example
Class: PHP Queue Jobs Piping
Send jobs to a pipeline to be executed later
Author: By
Last change:
Date: 1 year ago
Size: 1,442 bytes
 

Contents

Class file image Download
<?php
/**
 * @author stev leibelt <artodeto@bazzline.net>
 * @since 2014-11-08
 */

namespace Example\InputArray;

use
Net\Bazzline\Component\ProcessPipe\ExecutableInterface;
use
Net\Bazzline\Component\ProcessPipe\Pipe;

require_once
__DIR__ . '/../../../vendor/autoload.php';

/**
 * Class ProcessOne
 */
class ProcessOne implements ExecutableInterface
{
   
/**
     * @param mixed $input
     * @return mixed
     * @throws \Net\Bazzline\Component\ProcessPipe\ExecutableException
     */
   
public function execute($input = null)
    {
       
$input['name'] = 'bar';
       
$input['steps'][] = __METHOD__;
       
$input['times'][] = microtime(true);

        return
$input;
    }
}

/**
 * Class ProcessTwo
 */
class ProcessTwo implements ExecutableInterface
{
   
/**
     * @param mixed $input
     * @return mixed
     * @throws \Net\Bazzline\Component\ProcessPipe\ExecutableException
     */
   
public function execute($input = null)
    {
       
$input['name'] = 'foobar';
       
$input['steps'][] = __METHOD__;
       
$input['times'][] = microtime(true);

        return
$input;
    }
}

$input = array(
   
'name' => 'foo',
   
'steps' => array(),
   
'times' => array()
);
$pipe = new Pipe();

$pipe->pipe(
    new
ProcessOne(),
    new
ProcessTwo()
);

echo
'input' . PHP_EOL;
echo
var_export($input, true) . PHP_EOL;

$output = $pipe->execute($input);

echo
'output' . PHP_EOL;
echo
var_export($output, true) . PHP_EOL;

For more information send a message to info at phpclasses dot org.