Skip to content

Commit bf0ce11

Browse files
committed
Merge branch 'feature/issue-10' into develop
2 parents d46239d + b4fcafa commit bf0ce11

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

src/AbstractStructArrayBase.php

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,18 @@ public function item($index)
110110
*/
111111
public function add($item)
112112
{
113-
if (stripos(get_called_class(), 'array') !== false) {
114-
/**
115-
* init array
116-
*/
117-
if (!is_array($this->_get($this->getAttributeName()))) {
118-
$this->_set($this->getAttributeName(), []);
119-
}
120-
/**
121-
* current array
122-
*/
123-
$currentArray = $this->_get($this->getAttributeName());
124-
array_push($currentArray, $item);
125-
$this
126-
->_set($this->getAttributeName(), $currentArray)
127-
->setInternArray($currentArray)
128-
->setInternArrayIsArray(true)
129-
->setInternArrayOffset(0);
113+
// init array
114+
if (!is_array($this->_get($this->getAttributeName()))) {
115+
$this->_set($this->getAttributeName(), []);
130116
}
117+
// current array
118+
$currentArray = $this->_get($this->getAttributeName());
119+
array_push($currentArray, $item);
120+
$this
121+
->_set($this->getAttributeName(), $currentArray)
122+
->setInternArray($currentArray)
123+
->setInternArrayIsArray(true)
124+
->setInternArrayOffset(0);
131125
return $this;
132126
}
133127
/**
@@ -234,15 +228,13 @@ public function getInternArrayOffset()
234228
*/
235229
public function initInternArray($array = [], $internCall = false)
236230
{
237-
if (stripos(get_called_class(), 'array') !== false) {
238-
if (is_array($array) && count($array) > 0) {
239-
$this
240-
->setInternArray($array)
241-
->setInternArrayOffset(0)
242-
->setInternArrayIsArray(true);
243-
} elseif (!$internCall && property_exists($this, $this->getAttributeName())) {
244-
$this->initInternArray($this->_get($this->getAttributeName()), true);
245-
}
231+
if (is_array($array) && count($array) > 0) {
232+
$this
233+
->setInternArray($array)
234+
->setInternArrayOffset(0)
235+
->setInternArrayIsArray(true);
236+
} elseif (!$internCall && property_exists($this, $this->getAttributeName())) {
237+
$this->initInternArray($this->_get($this->getAttributeName()), true);
246238
}
247239
return $this;
248240
}

0 commit comments

Comments
 (0)