Skip to content

Commit b9a1ee1

Browse files
committed
Implements ArrayAccess for Relation class
Adds support for ArrayAccess to the Relation class, enabling array-like interactions with internal data. This includes the implementation of methods for checking, retrieving, setting, and unsetting elements in the data array. Enhances flexibility and usability of the Relation class.
1 parent 523afc6 commit b9a1ee1

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

debian/changelog

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
php-spojenet-abraflexi (3.6.1) UNRELEASED; urgency=medium
1+
php-spojenet-abraflexi (3.6.2) UNRELEASED; urgency=medium
2+
3+
* Relation now can hold values
4+
5+
-- vitex <info@vitexsoftware.cz> Fri, 12 Sep 2025 20:41:32 +0200
6+
7+
php-spojenet-abraflexi (3.6.1) experimental; urgency=medium
28

39
* Overpayment handling added
410
* jenkins-Spoje.Net-php-spojenet-abraflexi-310
@@ -8,7 +14,7 @@ php-spojenet-abraflexi (3.6.1) UNRELEASED; urgency=medium
814
* jenkins-Spoje.Net-php-spojenet-abraflexi-324
915
* jenkins-Spoje.Net-php-spojenet-abraflexi-325
1016

11-
-- vitex <jenkins@vyvojar.spoje.net> Thu, 31 Jul 2025 11:55:17 +0000
17+
-- vitex <info@vitexsoftware.cz> Fri, 12 Sep 2025 20:41:15 +0200
1218

1319
php-spojenet-abraflexi (3.5.4) experimental; urgency=medium
1420

src/AbraFlexi/Relation.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @no-named-arguments
2323
*/
24-
class Relation
24+
class Relation implements \ArrayAccess
2525
{
2626
/**
2727
* Item in target evidence.
@@ -34,6 +34,7 @@ class Relation
3434
public string $target;
3535
public ?string $ref;
3636
public ?string $showAs;
37+
protected array $data = [];
3738

3839
/**
3940
* Relation.
@@ -80,4 +81,24 @@ public function getRelationTarget()
8081

8182
return $relation;
8283
}
84+
85+
public function offsetExists(mixed $offset): bool
86+
{
87+
return \array_key_exists($offset, $this->data);
88+
}
89+
90+
public function offsetGet(mixed $offset): mixed
91+
{
92+
return $this->offsetExists($offset) ? $this->data[$offset] : null;
93+
}
94+
95+
public function offsetSet(mixed $offset, mixed $value): void
96+
{
97+
$this->data[$offset] = $value;
98+
}
99+
100+
public function offsetUnset(mixed $offset): void
101+
{
102+
unset($this->data[$offset]);
103+
}
83104
}

0 commit comments

Comments
 (0)