mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
The `Id`, `Name`, and `Path` value objects are not only message-related concerns, they're part of the core of the library, hence it makes sense to place them at the root namespace.
35 lines
596 B
PHP
35 lines
596 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation;
|
|
|
|
final class Path
|
|
{
|
|
public function __construct(
|
|
public int|string $value,
|
|
public Path|null $parent = null,
|
|
) {
|
|
}
|
|
|
|
public function isOrphan(): bool
|
|
{
|
|
return $this->parent === null;
|
|
}
|
|
|
|
public function withParent(self $parent): self
|
|
{
|
|
if ($parent === $this->parent) {
|
|
return $this;
|
|
}
|
|
|
|
$this->parent = $parent;
|
|
|
|
return $this;
|
|
}
|
|
}
|