Example #1
0
 /**
  * @covers Peach\DF\JsonCodec\Context::__construct
  * @covers Peach\DF\JsonCodec\Context::getOption
  */
 public function testGetOption()
 {
     $options = new ArrayMap();
     $options->put(JsonCodec::BIGINT_AS_STRING, true);
     $context = new Context("This is a pen.", $options);
     $this->assertFalse($context->getOption(JsonCodec::OBJECT_AS_ARRAY));
     $this->assertTrue($context->getOption(JsonCodec::BIGINT_AS_STRING));
 }
Example #2
0
 /**
  * number = [ minus ] int [ frac ] [ exp ]
  * 
  * @param \Peach\DF\JsonCodec\Context $context
  */
 public function handle(Context $context)
 {
     $this->bigNumAsString = $context->getOption(JsonCodec::BIGINT_AS_STRING);
     $this->handleMinus($context);
     $this->handleIntegralPart($context);
     $this->handleFractionPart($context);
     $this->handleExponentPart($context);
 }
Example #3
0
 /**
  * 
  * @param  Context $context
  * @return ObjectExpr_Container
  */
 private function getContainer(Context $context)
 {
     $asArray = $context->getOption(JsonCodec::OBJECT_AS_ARRAY);
     return $asArray ? new ObjectExpr_ArrayContainer() : new ObjectExpr_StdClassContainer();
 }