| Conditions | 4 |
| Paths | 6 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function build(Orm $orm, Mapper $mapper, string $name, array $options): Relation |
||
| 13 | { |
||
| 14 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
||
| 15 | if ($orm->has($foreignMapper)) { |
||
| 16 | if (! $foreignMapper instanceof Mapper) { |
||
| 17 | $foreignMapper = $orm->get($foreignMapper); |
||
| 18 | } |
||
| 19 | } |
||
| 20 | $type = $options[RelationConfig::TYPE]; |
||
| 21 | $relationClass = 'Sirius\\Orm\\Relation\\' . Str::className($type); |
||
| 22 | |||
| 23 | if (! class_exists($relationClass)) { |
||
| 24 | throw new InvalidArgumentException("{$relationClass} does not exist"); |
||
|
|
|||
| 25 | } |
||
| 26 | |||
| 27 | return new $relationClass($name, $mapper, $foreignMapper, $options); |
||
| 28 | } |
||
| 30 |