type() public method

Sets/gets the content type.
public type ( string $type = null ) : string
$type string A full content type i.e. `'application/json'` or simple name `'json'`
return string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending on the content type of the request.
Example #1
0
 /**
  * Sets/Gets the content type. If `'type'` is null, the method will attempt to determine the
  * type first, from the params, then from the environment setting
  *
  * @param string $type a full content type i.e. `'application/json'` or simple name `'json'`
  * @return string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending
  *         on the content type of the request.
  */
 public function type($type = null)
 {
     if ($type === null) {
         $type = $this->type;
         if (!$type) {
             $type = $this->env('CONTENT_TYPE');
         }
     }
     return parent::type($type);
 }