/** * @test * @expectedException \LitGroup\Json\Exception\JsonException */ public function testMaxDepthException() { $this->config->setMaxDepth(1); // Value with depth > 1 $value = ['sub_array' => []]; $this->encoder->encode($value); }
/** * {@inheritDoc} */ public function encode($value) { $result = json_encode($value, $this->config->getOptionsBitmask(), $this->config->getMaxDepth()); if (json_last_error() != JSON_ERROR_NONE) { throw new JsonException(json_last_error_msg(), json_last_error()); } return $result; }