/** * @param $method * @param $params * * @return $this */ public function __call($method, $params) { if (substr($method, 0, 5) == 'where') { $varName = S::camelCaseToSnakeCase(mb_substr($method, 5)); $this->{$varName} = $params[0]; } return $this; }
/** * @param $ob * @param string $typeName * * @return mixed */ public function castType($ob, $typeName = null) { if ($typeName === null) { $typeName = $this->typeName; } if ($ob instanceof \stdClass && isset($ob->{$typeName}) && $this->hasMapping($ob->{$typeName})) { $className = $this->getMapping($ob->{$typeName}); $newOb = new $className(); foreach ($ob as $key => $val) { $newOb->{StringHelper::noFirstCamelCase($key)} = $val; } return $newOb; } return $ob; }