public function serialize($data)
    {
        if (is_array($data) || (is_object($data) && !method_exists($data, '_toString'))) {
            throw new \InvalidArgumentException(__CLASS__ . ' can not handle an array or non-stringable object.');
        }

        return $data;
    }
public function serialize($data)
    {
        if (is_array($data) || (is_object($data) && !method_exists($data, '_toString'))) {
            throw new \InvalidArgumentException(__CLASS__ . ' can not handle an array or non-stringable object.');
        }

        return $data;
    }
public function serialize ( $ data ) { if ( is_array ( $ data ) || ( is_object ( $ data ) && ! method_exists ( $ data , '_toString' ) ) ) { throw new \ InvalidArgumentException ( __CLASS__ . ' can not handle an array or non-stringable object.' ) ; } return $ data ; }
Encode data.

@param   mixed $data

@throws \InvalidArgumentException
@return  string
Encode data .