Source of file HandlerTrait.php
Size: 1,720 Bytes - Last Modified: 2021-12-24T06:51:36+00:00
/var/www/docs.ssmods.com/process/src/src/Processor/HandlerTrait.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | <?php namespace Heystack\Core\Processor; /** * Provides standard processor handling functionality. * * Stores an array of processors and provides methods for setting, getting * and adding processors to the array. Forces traiting class to implement abstract methods. * * @author Cam Spiers <cameron@heyday.co.nz> * @package Heystack */ trait HandlerTrait { /** * Stores processors by an identifier key * @var array */ private $processors = []; /** * Return a processor by an identifier if it exists * @param string $name The processor identifier * @return mixed The processor if it exists */ public function getProcessor($name) { return isset($this->processors[$name]) ? $this->processors[$name] : false; } /** * Check if a processor is on the array * @param string $name The processor identifier * @return boolean Whether or not the processor exists */ public function hasProcessor($name) { return isset($this->processors[$name]); } /** * Return all processors * @return array The processors or an empty array */ public function getProcessors() { return $this->processors; } /** * Set processors explicitly. This method uses the addProcessor method which * should enforce what type of objects can be added to the array * @uses self::addProcessor * @param array $processors An array of processors * @return void */ public function setProcessors(array $processors) { $this->processors = []; foreach ($processors as $processor) { $this->addProcessor($processor); } } } |