to() публичный Метод

Adds conversions checks to ensure certain class types and embedded values are properly cast.
public to ( string $format, array $options = [] ) : mixed
$format string Currently only `array` is supported.
$options array
Результат mixed
Пример #1
0
 public function testHandlers()
 {
     $model = $this->_model;
     $schema = new DocumentSchema(array('fields' => array('_id' => array('type' => 'id'), 'date' => array('type' => 'date')), 'types' => array('date' => 'date'), 'handlers' => array('date' => function ($v) {
         return (object) $v;
     })));
     $handlers = array('stdClass' => function ($value) {
         return date('d/m/Y H:i', strtotime($value->scalar));
     });
     $array = new Document(compact('model', 'schema', 'handlers') + array('data' => array('_id' => '2', 'date' => '2013-06-06 13:00:00')));
     $expected = array('_id' => '2', 'date' => '06/06/2013 13:00');
     $this->assertIdentical($expected, $array->to('array', array('indexed' => false)));
 }