prepareOptions($options) as $name => $value) { if (!property_exists($this, $name)) { throw new InputException('Property ' . $name . ' does not exists for ' . $this::class . '.'); } $this->{$name} = $value; } return $this; } /** * This method makes it possible to call self::setOptions() with a single * array instead of named parameters * * @param array $options * @return array */ private function prepareOptions(array $options): array { if (count($options) === 0) { return $options; } if (count($options) > 1) { return $options; } if (!array_key_exists(0, $options)) { return $options; } if (!is_array($options[0])) { return $options; } return $options[0]; } }