Cast an param to a native PHP type.
@param  string  $key
@param  mixed  $value
@return mixed
357063
protected function castParam($key, $value)
    {
        if (is_null($value) or ! $this->hasCast($key)) {
            return $value;
        }

        switch ($this->getCastType($key)) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'string':
                return (string) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'array':
                return (array) $value;
            case 'collection':
                return collect((array) $value);
            default:
                return $value;
        }
    }
361225
protected function castAttribute($key, $value)
    {
        if ($value === null) {
            return $value;
        }

        if ($this->getCastType($key) === 'serialize') {
            return $this->fromSerialize($value);
        }

        return parent::castAttribute($key, $value);
    }
430353
protected function cast_attribute( $key, $value ) {
		if ( is_null( $value ) ) {
			return $value;
		}

		switch ( $this->get_cast_type( $key ) ) {
			case 'int':
			case 'integer':
				return (int) $value;
			case 'real':
			case 'float':
			case 'double':
				return (float) $value;
			case 'string':
				return (string) $value;
			case 'array':
				return (array) $value;
			case 'bool':
			case 'boolean':
				return (bool) $value;
			default:
				return $value;
		}
	}
969343
public function cast($value)
    {
        $fn = 'cast' . ucfirst(gettype($value));
        return method_exists($this, $fn) ? $this->$fn($value) : $this->dontCast($value);
    }
1076593
public function setParameter($key, $value)
    {
        if (!$this->parameters) {
            $this->parameters = array();
        }

        $this->parameters[$key] = $value;

        return $this;
    }
623155
public function setParam($key, $value = null)
    {

        return null !== $this->getDraft() ? $this->getDraft()->setParam($key, $value) : parent::setParam($key, $value);
    }
343337
protected function getDataTypeByValue($value)
    {
        if(null === $value)
        {
            return \PDO::PARAM_NULL;
        }
        if(is_bool($value))
        {
            return \PDO::PARAM_BOOL;
        }
        if(is_int($value))
        {
            return \PDO::PARAM_INT;
        }
        return \PDO::PARAM_STR;
    }
1306530
private function getValue(string $key, $value = null)
    {
        if (! is_null($this->language)) {
            $key = $this->language.'.'.$key;
        }

        if (! is_null($this->prefix)) {
            $key = $this->prefix.'.'.$key;
        }

        $data = $this->data->getContent($key);

        // default value
        if (is_null($data)) {
            return $value;
        }

        if ($value instanceof \Closure) {
            return $value($data, $this->data);
        }

        return $data;
    }
475597
public function append($value, $key = null): Arrayy
    {
        $this->checkTypeWrapper($value);

        return parent::append($value, $key);
    }
1289513
protected function castSetting($key, $value)
    {
        if (is_null($value)) {
            return $value;
        }

        if (!in_array($key, $this->notBooleans) && in_array($value, ['0', '1'])) {
            return (bool) $value;
        }

        return $value;
    }
41508
protected function castAttribute($key, $value)
    {
        if (($method = $this->getCastFromMethod($key)) === false) {
            return $value;
        }

        if (stripos($method, 'date') === false && is_null($value)) {
            return $value;
        }

        // Casting method is local.
        if (is_string($method) && method_exists($this, $method)) {
            $paramaters = $this->getCastAsParamaters($key);

            return $this->$method($value, ...$paramaters);
        }

        return $value;
    }
623086
public function setParam($key, $value)
    {
        if(!isset($this->params[$key]) || $this->params[$key] === []) {
            $this->params[$key] = $value;
        }
        else {
            $this->params[$key] = array_merge($this->params[$key], [$value]);
        }
        return $this;
    }
427193
private function bindDataType($value)
    {
        switch (true) {
            case is_string($value):
                return PDO::PARAM_STR;
            case is_int($value):
                return PDO::PARAM_INT;
            case is_bool($value):
                return PDO::PARAM_BOOL;
            case is_null($value):
                return PDO::PARAM_NULL;
            default:
                return false;
        }
    }
209038
public static function cast( $value, $phpType ) {
		if( $phpType === null or $value === null ) return $value;
		
		switch( $phpType ) {
		case 'string': return (string)$value;
		case 'float': return (float)$value;
		case 'int': return (int)$value;
		case 'bool':
			if( is_bool($value) ) return $value;
			if( is_numeric($value) ) {
				if( $value == 1 ) return true;
				if( $value == 0 ) return false;
			}
			if( is_string($value) ) {
				if( in_array($value, array('yes','true','on')) ) return true;
				if( in_array($value, array('no','false','off','')) ) return false;
			}
			throw new Exception("Invalid boolean representation: ".var_export($value,true));
		default:
			throw new Exception("Don't know how to cast to PHP type '$phpType'.");
		}
	}
1354148
protected function mutateMetableAttribute(string $key, $value): ?string
    {
        if (\is_null($value)) {
            return $value;
        }

        if ($value instanceof Arrayable) {
            $value = $value->toArray();
        } elseif (! \is_array($value)) {
            $value = (array) $value;
        }

        return $this->castAttributeAsJson($key, $value);
    }
661128
public function set(string $key, $value, int $type = PDO::PARAM_STR)
    {
        $this->params[$key] = $value;
        $this->param_types[$key] = $type;
        return $this;
    }
327831
public function setParam($key = null, $value = null)
    {
        if(is_array($key))
            Arr::set($this->serviceData, 'param', array_merge($this->getService('param'),$key));
        else{
            if (Arr::has($this->serviceData, 'param.' . $key))
                Arr::set($this->serviceData, 'param.' . $key, $value);
        }
        return $this;
    }