src/Model/BaseModel.php
/**
     * Initialize this object's properties from an array.
     *
     * @param array $properties Used to seed this object's properties.
     */
Initialize this object's properties from an array.
@param array $properties Used to seed this object's properties.
Initialize this object ' s properties from an array . @param array $properties Used to seed this object ' s properties .
protected function mapTypes(array $properties = []): void
    {
        foreach ($properties as $key => $val) {
            $ucFirst = ucfirst($key);
            $setter = 'set' . $ucFirst;
            $camelKey = $this->camelCase($key);
            $propertyType = null;
            if (property_exists($this, $key)) {
                $propertyType = ReadDocsHelper::detectPropertyType(get_class($this), $key);
            } elseif (property_exists($this, $camelKey)) {
                $propertyType = ReadDocsHelper::detectPropertyType(get_class($this), $camelKey);
            }
            if (!empty($propertyType) && class_exists($propertyType)) {
                $propertyParent = get_parent_class($propertyType);
                if ($propertyParent === BaseModel::class || $propertyParent === Collection::class) {
                    $val = new $propertyType($val);
                }
            }
            if (method_exists($this, $setter)) {
                $this->$setter($val);
                unset($properties[$key]);
            } elseif (property_exists($this, $camelKey)) {
                $setter = 'set' . $ucFirst;
                $this->$setter($val);
                unset($properties[$key]);
            }
        }
        $this->otherProperties = $properties;
    }
protected function mapTypes ( array $ properties = [ ] ) : void { foreach ( $ properties as $ key => $ val ) { $ ucFirst = ucfirst ( $ key ) ; $ setter = 'set' . $ ucFirst ; $ camelKey = $ this -> camelCase ( $ key ) ; $ propertyType = null ; if ( property_exists ( $ this , $ key ) ) { $ propertyType = ReadDocsHelper :: detectPropertyType ( get_class ( $ this ) , $ key ) ; } elseif ( property_exists ( $ this , $ camelKey ) ) { $ propertyType = ReadDocsHelper :: detectPropertyType ( get_class ( $ this ) , $ camelKey ) ; } if ( ! empty ( $ propertyType ) && class_exists ( $ propertyType ) ) { $ propertyParent = get_parent_class ( $ propertyType ) ; if ( $ propertyParent === BaseModel :: class || $ propertyParent === Collection :: class ) { $ val = new $ propertyType ( $ val ) ; } } if ( method_exists ( $ this , $ setter ) ) { $ this -> $ setter ( $ val ) ; unset ( $ properties [ $ key ] ) ; } elseif ( property_exists ( $ this , $ camelKey ) ) { $ setter = 'set' . $ ucFirst ; $ this -> $ setter ( $ val ) ; unset ( $ properties [ $ key ] ) ; } } $ this -> otherProperties = $ properties ; }
Initialize this object's properties from an array.
Initialize this object ' s properties from an array .