/** * * @return array */ public function __toArray() { $returnArray = parent::__toArray(); if (isset($returnArray['data'])) { foreach ($returnArray['data'] as $index => $item) { $returnArray['data'][$index] = Factory::create(json_encode($item))->__toArray(); } } return $returnArray; }
public function __construct($json) { parent::__construct($json); $this->setDataProperty('object', ObjectFactory::create(json_encode($this->getDataProperty('object')))); if ($this->hasPreviousAttributes()) { $previousAttributesCollection = new ArrayCollection(); foreach ($this->getPreviousAttributes() as $key => $value) { if ($value instanceof \stdClass && isset($value->object) && ObjectFactory::isKnownEntityType($value->object)) { $value = ObjectFactory::create(json_encode($value)); } $previousAttributesCollection->set($key, $value); } $this->setDataProperty('previous_attributes', $previousAttributesCollection); } }
public function setUp() { $this->setTestFixturePath(get_class($this)); $this->object = Factory::create($this->getFixture('object.json')); }
public function testDiscount() { $this->assertInstanceOf('webignition\\Model\\Stripe\\Discount', Factory::create($this->getFixture('Discount/discount.json'))); }