toObject() public static method

Create an object from an array.
public static toObject ( array $array ) : object
$array array
return object
Ejemplo n.º 1
0
 public function get($imageId)
 {
     // get the real full image path to display this file.
     $data = StorageImage::find()->where(['id' => $imageId])->with('file')->one();
     if (!$data || !isset($data->file)) {
         return false;
     }
     $fileName = implode([$data->filter_id, $data->file->name_new_compound], '_');
     return ArrayHelper::toObject(['filter_id' => $data->filter_id, 'file_id' => $data->file_id, 'file_is_deleted' => $data->file->is_deleted, 'image_id' => $data->id, 'file_source' => $data->file->name_new_compound, 'image_source' => $fileName, 'source' => \yii::$app->storage->httpDir . $fileName]);
 }
Ejemplo n.º 2
0
 public function testToObject()
 {
     $this->assertTrue(is_object(ArrayHelper::toObject(['foo' => 'bar'])));
     $this->assertEquals('bar', ArrayHelper::toObject(['foo' => 'bar'])->foo);
 }