Add without() Method
This commit is contained in:
@@ -11,4 +11,5 @@ abstract class AbstractAware implements AwareInterface
|
|||||||
abstract protected function set(string $key, mixed $value): mixed;
|
abstract protected function set(string $key, mixed $value): mixed;
|
||||||
abstract protected function unset(string $key): void;
|
abstract protected function unset(string $key): void;
|
||||||
abstract public function with(string $key, mixed $value): AwareInterface;
|
abstract public function with(string $key, mixed $value): AwareInterface;
|
||||||
|
abstract public function without(string $key): AwareInterface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ interface AwareInterface
|
|||||||
public function get(string $key): mixed;
|
public function get(string $key): mixed;
|
||||||
public function has(string $key): bool;
|
public function has(string $key): bool;
|
||||||
public function with(string $key, mixed $value): self;
|
public function with(string $key, mixed $value): self;
|
||||||
|
public function without(string $key): self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,10 @@ trait AwareTrait
|
|||||||
($clone = $this->clone())->set($key, $value);
|
($clone = $this->clone())->set($key, $value);
|
||||||
return $clone;
|
return $clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function without(string $key): AwareInterface
|
||||||
|
{
|
||||||
|
($clone = $this->clone())->unset($key);
|
||||||
|
return $clone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user