value() public static method

public static value ( )
Ejemplo n.º 1
0
 /**
  * @test
  */
 public function shouldSetContentType()
 {
     //given
     $_SERVER['CONTENT_TYPE'] = 'application/json';
     //when
     ContentType::set('text/plain');
     //then
     $this->assertEquals('text/plain', ContentType::value());
 }
Ejemplo n.º 2
0
 public static function resolve()
 {
     $accept = array_keys(RequestHeaders::accept()) ?: array('*/*');
     $supported = array('application/json' => 'application/json', 'application/xml' => 'application/xml', 'application/*' => 'application/json', 'text/html' => 'text/html', 'text/*' => 'text/html');
     $intersection = array_intersect($accept, array_keys($supported));
     if ($intersection) {
         return $supported[Arrays::first($intersection)];
     }
     return Arrays::getValue($supported, ContentType::value(), 'text/html');
 }
Ejemplo n.º 3
0
 private static function _putRequestParameters($content)
 {
     if (Strings::equal(Arrays::getValue($_SERVER, 'REQUEST_METHOD'), 'PUT') && Strings::equalsIgnoreCase(ContentType::value(), 'application/x-www-form-urlencoded')) {
         parse_str($content, $parameters);
         return Arrays::toArray($parameters);
     }
     return false;
 }