private function setValue($value)
    {
        switch (gettype($value)) {
            case 'int':
            case 'integer':
                $this->attributes['type'] = 'int';

                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                $this->attributes['type'] = 'float';

                return (float) $value;
            case 'bool':
            case 'boolean':
                $this->attributes['type'] = 'bool';

                return (bool) $value;
            case 'object':
                if ($value instanceof Collection) {
                    $this->attributes['type'] = 'collection';

                    return json_encode($value);
                }
                $this->attributes['type'] = 'object';

                return json_encode($value);
            case 'array':
                $this->attributes['type'] = 'array';

                return json_encode($value);
            default:
                $this->attributes['type'] = 'string';

                return $value;
        }
    }
private function setValue($value)
    {
        switch (gettype($value)) {
            case 'int':
            case 'integer':
                $this->attributes['type'] = 'int';

                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                $this->attributes['type'] = 'float';

                return (float) $value;
            case 'bool':
            case 'boolean':
                $this->attributes['type'] = 'bool';

                return (bool) $value;
            case 'object':
                if ($value instanceof Collection) {
                    $this->attributes['type'] = 'collection';

                    return json_encode($value);
                }
                $this->attributes['type'] = 'object';

                return json_encode($value);
            case 'array':
                $this->attributes['type'] = 'array';

                return json_encode($value);
            default:
                $this->attributes['type'] = 'string';

                return $value;
        }
    }
private function setValue ( $ value ) { switch ( gettype ( $ value ) ) { case 'int' : case 'integer' : $ this -> attributes [ 'type' ] = 'int' ; return ( int ) $ value ; case 'real' : case 'float' : case 'double' : $ this -> attributes [ 'type' ] = 'float' ; return ( float ) $ value ; case 'bool' : case 'boolean' : $ this -> attributes [ 'type' ] = 'bool' ; return ( bool ) $ value ; case 'object' : if ( $ value instanceof Collection ) { $ this -> attributes [ 'type' ] = 'collection' ; return json_encode ( $ value ) ; } $ this -> attributes [ 'type' ] = 'object' ; return json_encode ( $ value ) ; case 'array' : $ this -> attributes [ 'type' ] = 'array' ; return json_encode ( $ value ) ; default : $ this -> attributes [ 'type' ] = 'string' ; return $ value ; } }
Internal function utilized by setValueAttribute to find the value type and set the attribute accordingly.

@param $value
@return bool|float|int|string
Internal function utilized by setValueAttribute to find the value type and set the attribute accordingly .