| Total Complexity | 5 | 
| Total Lines | 48 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 20 | trait Publisher  | 
            ||
| 21 | { | 
            ||
| 22 | protected array $listeners = [];  | 
            ||
| 23 | |||
| 24 | |||
| 25 | /**  | 
            ||
| 26 | * Adds a listener object to the publisher.  | 
            ||
| 27 | *  | 
            ||
| 28 | * @param \Aimeos\MShop\Plugin\Provider\Iface $l Object implementing listener interface  | 
            ||
| 29 | * @param string $action Name of the action to listen for  | 
            ||
| 30 | * @return \Aimeos\MShop\Order\Item\Iface Publisher object for method chaining  | 
            ||
| 31 | */  | 
            ||
| 32 | public function attach( \Aimeos\MShop\Plugin\Provider\Iface $l, string $action ) : Iface  | 
            ||
| 33 | 	{ | 
            ||
| 34 | $this->listeners[$action][] = $l;  | 
            ||
| 35 | return $this;  | 
            ||
| 36 | }  | 
            ||
| 37 | |||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Removes all attached listeners from the publisher  | 
            ||
| 41 | *  | 
            ||
| 42 | * @return \Aimeos\MShop\Order\Item\Iface Publisher object for method chaining  | 
            ||
| 43 | */  | 
            ||
| 44 | public function off() : Iface  | 
            ||
| 45 | 	{ | 
            ||
| 46 | $this->listeners = [];  | 
            ||
| 47 | return $this;  | 
            ||
| 48 | }  | 
            ||
| 49 | |||
| 50 | |||
| 51 | /**  | 
            ||
| 52 | * Sends updates to all listeners of the given action.  | 
            ||
| 53 | *  | 
            ||
| 54 | * @param string $action Name of the action  | 
            ||
| 55 | * @param mixed $value Value or object given to the listeners  | 
            ||
| 56 | * @return mixed Modified value parameter  | 
            ||
| 57 | */  | 
            ||
| 58 | protected function notify( string $action, $value = null )  | 
            ||
| 68 | }  | 
            ||
| 69 | }  | 
            ||
| 70 |