Skip to content

Commit 94570c3

Browse files
committed
style(collection): rename collections array to typesenseCollection
* rename array variable to avoid reserving the `collections` name for collections * the get magic method checks if the name passed is set, and returns that * if the name matches the term `collections`, the array would be returned instead
1 parent eb32032 commit 94570c3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Collections.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Collections implements \ArrayAccess
2424
/**
2525
* @var array
2626
*/
27-
private array $collections = [];
27+
private array $typesenseCollections = [];
2828

2929
/**
3030
* Collections constructor.
@@ -46,11 +46,11 @@ public function __get($collectionName)
4646
if (isset($this->{$collectionName})) {
4747
return $this->{$collectionName};
4848
}
49-
if (!isset($this->collections[$collectionName])) {
50-
$this->collections[$collectionName] = new Collection($collectionName, $this->apiCall);
49+
if (!isset($this->typesenseCollections[$collectionName])) {
50+
$this->typesenseCollections[$collectionName] = new Collection($collectionName, $this->apiCall);
5151
}
5252

53-
return $this->collections[$collectionName];
53+
return $this->typesenseCollections[$collectionName];
5454
}
5555

5656
/**
@@ -79,34 +79,34 @@ public function retrieve(): array
7979
*/
8080
public function offsetExists($offset): bool
8181
{
82-
return isset($this->collections[$offset]);
82+
return isset($this->typesenseCollections[$offset]);
8383
}
8484

8585
/**
8686
* @inheritDoc
8787
*/
8888
public function offsetGet($offset): Collection
8989
{
90-
if (!isset($this->collections[$offset])) {
91-
$this->collections[$offset] = new Collection($offset, $this->apiCall);
90+
if (!isset($this->typesenseCollections[$offset])) {
91+
$this->typesenseCollections[$offset] = new Collection($offset, $this->apiCall);
9292
}
9393

94-
return $this->collections[$offset];
94+
return $this->typesenseCollections[$offset];
9595
}
9696

9797
/**
9898
* @inheritDoc
9999
*/
100100
public function offsetSet($offset, $value): void
101101
{
102-
$this->collections[$offset] = $value;
102+
$this->typesenseCollections[$offset] = $value;
103103
}
104104

105105
/**
106106
* @inheritDoc
107107
*/
108108
public function offsetUnset($offset): void
109109
{
110-
unset($this->collections[$offset]);
110+
unset($this->typesenseCollections[$offset]);
111111
}
112112
}

0 commit comments

Comments
 (0)