for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Stadly\PasswordPolice\Formatter;
use Stadly\PasswordPolice\CharTree;
use Stadly\PasswordPolice\Formatter;
trait Chaining
{
/**
* @var Formatter|null Next character tree formatter in the chain.
*/
private $next = null;
* @param Formatter|null $next Formatter to apply after this one.
public function setNext(?Formatter $next): void
$this->next = $next;
}
* @return Formatter|null Next formatter in the chain.
public function getNext(): ?Formatter
return $this->next;
* @param CharTree $charTree Character tree to format.
* @return CharTree The character tree formatted by the formatter chain.
public function apply(CharTree $charTree): CharTree
if ($this->next === null) {
return $this->applyCurrent($charTree);
} else {
return $this->next->apply($this->applyCurrent($charTree));
* @return CharTree The character tree formatted by this formatter.
abstract protected function applyCurrent(CharTree $charTree): CharTree;