maxDepth = $maxDepth; $this->currentDepth = $currentDepth; } /** @return self */ public static function initial() { return self::maxDepth(256); } /** * @param int $maxDepth * @return self */ public static function maxDepth($maxDepth) { return new self($maxDepth, 0); } /** @return self */ public function incremented() { return new self($this->maxDepth, $this->currentDepth + 1); } /** @return bool */ public function isDepthExceeded() { return ($this->maxDepth < $this->currentDepth); } }