Esempio n. 1
0
 /**
  * Get the CBOR payload for the request.
  *
  * @param  string  $key The key to get the value for, in "dot notation" (ex: user.username = cbor["user"]["username"]).
  * @param  mixed   $default Default value if the key isn't found.
  * @return mixed
  */
 public function cbor($key = null, $default = null)
 {
     //Grab the content
     $content = $this->getContent();
     //Deal with empty input.
     if (empty($content)) {
         return null;
     }
     //Don't decode twice!
     if (!isset($this->cbor)) {
         $this->cbor = new ParameterBag((array) Cbor::decode($content, true));
     }
     //Return the whole array if no key was specified
     if (is_null($key)) {
         return $this->cbor;
     }
     //Get key value in dot notation
     return array_get($this->cbor->all(), $key, $default);
 }
Esempio n. 2
0
 /**
  * Get the cbor decoded data from the response
  *
  * @return mixed
  */
 public function getData()
 {
     return Cbor::decode($this->data);
 }
Esempio n. 3
0
 function testAbruptStringEnd()
 {
     $this->setExpectedException(CBOR_EXCEPTION);
     Cbor::decode(pack('C*', 0b1111011, 97, 98));
 }