nerio/model-reflector

Reflect array to model

dev-master 2020-05-08 02:51 UTC

This package is auto-updated.

Last update: 2020-08-08 03:23:38 UTC


README

 
<?php
namespace App\Lib;
use Nerio\ModelReflector\ModelReflector;
class User extends ModelReflector
{
    public $name;
    public $age;

    /**
     * @var UserInfo
     */
    public $info;
}
<?php 

namespace App\Lib;
use Nerio\ModelReflector\ModelReflector;

/**
 * @author caojiayuan
 */
class UserInfo extends ModelReflector
{
    public $desc;
    public $avatar;
}
<?php
$map = \App\Lib\User::make([
   'name' => 'Tom',
   'age'  => 19,
   'info' => [
       'desc' => "I'm Tom",
       'avatar' => 'http://xxxxx.jpg'
   ]
]);

echo $map->info->avatar;