aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Model/PushableModel.php
blob: c008320eae417b5f44bd27abb790bfef799eef57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
namespace Digitigrade\Model;

abstract class PushableModel extends FetchableModel implements \JsonSerializable {
    public ?int $id;
    public string $uri;

    public static function importFromReceivedObject(\stdClass $data, bool $autoSave = true): static {
        $obj = static::createFromJson($data, $autoSave);
        if ($autoSave) {
            $obj->save();
            $obj->finaliseAfterSave();
        }
        return $obj;
    }
}