Пример #1
0
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @throws  \RuntimeException
  */
 public function render()
 {
     if ($this->data instanceof Registry) {
         return $this->data->toString('json', array('options' => $this->options, 'depth' => $this->depth));
     }
     if (version_compare(PHP_VERSION, '5.5', '<')) {
         return json_encode($this->data, $this->options);
     } else {
         return json_encode($this->data, $this->options, $this->depth);
     }
 }
 /**
  * Get a namespace in a given string format
  *
  * @param   string  $format   Format to return the string in
  * @param   mixed   $options  Parameters used by the formatter, see formatters for more info
  *
  * @return  string   Namespace in string format
  *
  * @since   1.0
  */
 public function toString($format = 'JSON', $options = array())
 {
     $this->registry->toString($format, $options);
 }
Пример #3
0
 /**
  * Method to test toString().
  *
  * @return void
  *
  * @covers Windwalker\Registry\Registry::toString
  */
 public function testToString()
 {
     $registry = new Registry($this->getTestData());
     $this->assertEquals($this->loadFile(__DIR__ . '/Stubs/flower.json'), $this->clean($registry->toString('json')));
     $this->assertEquals($this->loadFile(__DIR__ . '/Stubs/flower.yml'), $this->clean($registry->toString('yaml')));
     $this->assertEquals($this->loadFile(__DIR__ . '/Stubs/flower.ini'), $this->clean($registry->toString('ini')));
     $this->assertEquals($this->loadFile(__DIR__ . '/Stubs/flower.xml'), $this->clean($registry->toString('xml')));
     $this->assertEquals($this->loadFile(__DIR__ . '/Stubs/flower.php'), $this->clean($registry->toString('php')));
 }