src/Service/EntityEraser/DependencyResultCollection.php
private function addArray(array $result)
    {
        if (1 < count($result) && !isset($result['name']) && !is_string($result[0])) {
            foreach ($result as $r) {
                if (is_array($r)) {
                    $this->add($r);
                } else {
                    return $this->addTraversable(new \ArrayIterator($result));
                }
            }
            return $this;
        }

        if (is_string($result[0])) {
            $result = [
                'name' => $result[0],
                'entities' => isset($result[1]) ? $result[1] : null,
                'options' => isset($result[2]) && is_array($result[2])
                    ? $result[2]
                    : [
                        'description' => isset($result[2]) ? $result[2] : null,
                        'viewScript' => isset($result[3]) ? $result[3] : null,
                      ],
            ];
        }

        if (!isset($result['name']) || !isset($result['entities'])) {
            throw new \UnexpectedValueException('Array must have the keys "name" and "entities".');
        }

        if (!count($result['entities'])) {
            throw new \UnexpectedValueException('Entities must be non-empty.');
        }

        $result = new DependencyResult($result['name'], $result['entities'], isset($result['options']) ? $result['options'] : null);

        return $this->addResult($result);
    }
private function addArray(array $result)
    {
        if (1 < count($result) && !isset($result['name']) && !is_string($result[0])) {
            foreach ($result as $r) {
                if (is_array($r)) {
                    $this->add($r);
                } else {
                    return $this->addTraversable(new \ArrayIterator($result));
                }
            }
            return $this;
        }

        if (is_string($result[0])) {
            $result = [
                'name' => $result[0],
                'entities' => isset($result[1]) ? $result[1] : null,
                'options' => isset($result[2]) && is_array($result[2])
                    ? $result[2]
                    : [
                        'description' => isset($result[2]) ? $result[2] : null,
                        'viewScript' => isset($result[3]) ? $result[3] : null,
                      ],
            ];
        }

        if (!isset($result['name']) || !isset($result['entities'])) {
            throw new \UnexpectedValueException('Array must have the keys "name" and "entities".');
        }

        if (!count($result['entities'])) {
            throw new \UnexpectedValueException('Entities must be non-empty.');
        }

        $result = new DependencyResult($result['name'], $result['entities'], isset($result['options']) ? $result['options'] : null);

        return $this->addResult($result);
    }
Add an array.

please see {@link add} for a list of possible values.

@param array $result

@return self