Page MenuHomeDevCentral

D3228.id8286.diff
No OneTemporary

D3228.id8286.diff

diff --git a/omnitools/src/Booleans/Boolean.php b/omnitools/src/Booleans/Boolean.php
--- a/omnitools/src/Booleans/Boolean.php
+++ b/omnitools/src/Booleans/Boolean.php
@@ -3,7 +3,7 @@
namespace Keruald\OmniTools\Booleans;
-class Boolean {
+readonly class Boolean {
///
/// Properties
@@ -32,43 +32,41 @@
///
public function and (self|bool $other) : self {
- if ($this->value === true) {
- $this->value = self::toScalar($other);
- }
+ $newValue = match($this->value) {
+ true => self::toScalar($other),
+ false => false,
+ };
- return $this;
+ return new self($newValue);
}
public function or (self|bool $other) : self {
- if ($this->value === false) {
- $this->value = self::toScalar($other);
- }
+ $newValue = match($this->value) {
+ true => true,
+ false => self::toScalar($other),
+ };
- return $this;
+ return new self($newValue);
}
public function xor (self|bool $other) : self {
- $this->value = ($this->value xor self::toScalar($other));
+ $newValue = ($this->value xor self::toScalar($other));
- return $this;
+ return new self($newValue);
}
public function not () : self {
- $this->value = !$this->value;
-
- return $this;
+ return new self(!$this->value);
}
public function implication (self|bool $other) : self {
- $this->value = $this->value === false || self::toScalar($other);
+ $newValue = $this->value === false || self::toScalar($other);
- return $this;
+ return new self($newValue);
}
public function equivalence (self|bool $other) : self {
- $this->value = $this->isEqualsTo($other);
-
- return $this;
+ return new self($this->isEqualsTo($other));
}
///

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 19:31 (19 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250657
Default Alt Text
D3228.id8286.diff (1 KB)

Event Timeline