You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace App\Contexts\Model;
-
- use App\Features\InstanceAble;
- use Illuminate\Database\Eloquent\Model;
- use LogicException;
-
- /**
- * @template TValue of Model
- */
- abstract class ModelContext
- {
- use InstanceAble;
-
- /** @var ?TValue $model */
- private ?Model $model = null;
-
- /**
- * @param TValue $model
- * @param boolean $override
- * @return void
- */
- public function set($model, bool $override = false)
- {
- if ($this->model !== null && $override === false) {
- throw new LogicException("コンテキスト 不正オーバーライド");
- }
- $this->model = $model;
- }
-
- /**
- * @return TValue
- */
- public function get()
- {
- return $this->model;
- }
- }
|