getContentType() public method

public getContentType ( )
Beispiel #1
0
 public function getEncodedData()
 {
     $data = $this->getData();
     if (in_array($this->object->getContentType(), ['application/json', 'text/json'])) {
         return json_encode($data);
     }
     return rawurlencode($data);
 }
Beispiel #2
0
 public function getEncodedData()
 {
     $data = $this->getData();
     if (in_array($this->object->getContentType(), ['application/json', 'text/json'])) {
         return json_encode($data);
     } elseif (in_array($this->object->getContentEncoding(), ['base64'])) {
         return base64_encode($data);
     } elseif (in_array($this->object->getContentEncoding(), ['binary', 'none'])) {
         return $data;
     }
     return rawurlencode($data);
 }
Beispiel #3
0
 public function testConstruct()
 {
     // simple new object
     $object = new Object();
     $this->assertEmpty($object->getData());
     // more complex object
     $data = new \StdClass();
     $data->woot = 'sauce';
     $object = new Object($data, ['Content-Type' => 'text/plain']);
     $this->assertEquals('sauce', $object->getData()->woot);
     $this->assertEquals('text/plain', $object->getContentType());
 }