Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace Mascame\Artificer\Fields; |
||
12 | public function getRelatedModel() |
||
13 | { |
||
14 | if ($this->relatedModel) return $this->relatedModel; |
||
|
|||
15 | |||
16 | $modelName = $this->getRelationAttribute('model'); |
||
17 | |||
18 | if (isset($this->modelObject->schema->models[$modelName])) { |
||
19 | return $this->relatedModel = $this->modelObject->schema->models[$modelName]; |
||
20 | } |
||
21 | |||
22 | throw new \Exception("Couldn't find the related model for '{$this->getName()}''"); |
||
23 | } |
||
24 | |||
61 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: