/** * @param array $ensureIsArray * @param array $keyMap * @return array */ protected function prepareParametersFromArguments($ensureIsArray = [], $keyMap = []) { $call = debug_backtrace(false)[1]; $class = $call['class']; $method = $call['function']; $arguments = $call['args']; $reflection = new \ReflectionMethod($class, $method); $reflectionParameters = $reflection->getParameters(); $parameters = []; foreach ($reflectionParameters as $id => $reflectionParameter) { $originalKey = $reflectionParameter->getName(); $key = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', Utils::getFrom($keyMap, $originalKey, $originalKey))); // will fail on required values // but without them you cannot get here $parameters[$key] = isset($arguments[$id]) ? $arguments[$id] : $reflectionParameter->getDefaultValue(); if (in_array($originalKey, $ensureIsArray)) { $parameters[$key] = $this->ensureIsArray($parameters[$key]); } } return $this->prepareParameters($parameters); }
public function getQueryParameters() { $parameters = []; $reflection = new \ReflectionObject($this); $reflectionParameters = $reflection->getProperties(ReflectionProperty::IS_PROTECTED); $ensureIsArray = $this->ensureIsArray; $keyMap = $this->keyMap; foreach ($reflectionParameters as $id => $reflectionParameter) { $originalKey = $reflectionParameter->getName(); if (in_array($originalKey, ['ensureIsArray', 'keyMap'])) { continue; } $key = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', Utils::getFrom($keyMap, $originalKey, $originalKey))); // will fail on required values // but without them you cannot get here $parameters[$key] = method_exists($this, 'is' . ucfirst($originalKey)) ? $this->{'is' . ucfirst($originalKey)}() : $this->{'get' . ucfirst($originalKey)}(); if (in_array($originalKey, $ensureIsArray)) { $parameters[$key] = $this->ensureIsArray($parameters[$key]); } } return array_filter($parameters); }
/** * @param $array * @param $class * @return array */ protected function arrayToObjectOfClass($array, $class) { $connection = $this->getRequest()->getConnection(); return Utils::convertArrayToArrayOfObjects($array, $class, $this->getRequest()->getParameters(), $connection); }
public function getForwardedMessages() { $messages = $this->getRawValue('fwd_messages'); return Utils::convertArrayToArrayOfObjects($messages, static::class, [], $this->getConnection()); }
/** * @param BasicEntity $extendedEntity */ protected function mergeWith(BasicEntity $extendedEntity = null) { if (is_null($extendedEntity)) { return; } $this->data = Utils::mergeObjects($this->data, $extendedEntity->getRawData()); }