contract = $contract; $this->initialized = true; return $this; } public function initForCreate(): static { $contract = new Contract(); $contract->setId(); $this->contract = $contract; $this->initialized = true; return $this; } public function fill(array $attr): static { if (!$this->initialized) { throw new LogicException("初期化ミス"); } $this->contract->fill($attr); return $this; } public function id(): string { if (!$this->initialized) { throw new LogicException("初期化ミス"); } return $this->contract->id; } // ----------------PROTECTED---------- protected function save(): static { $this->contract->save(); return $this; } }