protected function appendProcessor(Processor $processor, int $stage, int $precedence = ProcessChain::RUN_DEFAULT)
    {
        $stage = WF::clamp($stage, static::STAGE_FILTER, static::STAGE_POSTPROCESS);
        $precedence = WF::clamp($precedence, static::RUN_FIRST, static::RUN_LAST);
        $this->processors[] = [
            'precedence' => $precedence, 
            'stage' => $stage, 
            'seq' => ++$this->seq, 
            'processor' => $processor
        ];

        // Sort the processors, first on stage, then on precedence, finally on order of appending
        usort($this->processors, function ($l, $r) {
            if ($l['stage'] != $r['stage'])
                return $l['stage'] - $r['stage'];
            if ($l['precedence'] != $r['precedence'])
                return $l['precedence'] - $r['precedence'];
            return $l['seq'] - $r['seq'];
        });
        return $this;
    }
protected function appendProcessor(Processor $processor, int $stage, int $precedence = ProcessChain::RUN_DEFAULT)
    {
        $stage = WF::clamp($stage, static::STAGE_FILTER, static::STAGE_POSTPROCESS);
        $precedence = WF::clamp($precedence, static::RUN_FIRST, static::RUN_LAST);
        $this->processors[] = [
            'precedence' => $precedence, 
            'stage' => $stage, 
            'seq' => ++$this->seq, 
            'processor' => $processor
        ];

        // Sort the processors, first on stage, then on precedence, finally on order of appending
        usort($this->processors, function ($l, $r) {
            if ($l['stage'] != $r['stage'])
                return $l['stage'] - $r['stage'];
            if ($l['precedence'] != $r['precedence'])
                return $l['precedence'] - $r['precedence'];
            return $l['seq'] - $r['seq'];
        });
        return $this;
    }
protected function appendProcessor ( Processor $ processor , int $ stage , int $ precedence = ProcessChain :: RUN_DEFAULT ) { $ stage = WF :: clamp ( $ stage , static :: STAGE_FILTER , static :: STAGE_POSTPROCESS ) ; $ precedence = WF :: clamp ( $ precedence , static :: RUN_FIRST , static :: RUN_LAST ) ; $ this -> processors [ ] = [ 'precedence' => $ precedence , 'stage' => $ stage , 'seq' => ++ $ this -> seq , 'processor' => $ processor ] ; // Sort the processors, first on stage, then on precedence, finally on order of appending usort ( $ this -> processors , function ( $ l , $ r ) { if ( $ l [ 'stage' ] != $ r [ 'stage' ] ) return $ l [ 'stage' ] - $ r [ 'stage' ] ; if ( $ l [ 'precedence' ] != $ r [ 'precedence' ] ) return $ l [ 'precedence' ] - $ r [ 'precedence' ] ; return $ l [ 'seq' ] - $ r [ 'seq' ] ; } ) ; return $ this ; }
Helper to add a processor to the pipeline

@param Wedeto\HTTP\Processor $processor The processor to add
@param int $stage The stage - STAGE_PREPROCESS, STAGE_PROCESS or STAGE_POSTPROCESS
@param int $precedence The precedence of the processor - the lower, the sooner it will be placed
in its stage.
@return $this Provides fluent interface
Helper to add a processor to the pipeline