Passed
Pull Request — 1.x (#12)
by
unknown
29:27 queued 14:24
created

RelationMapper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 11
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A map() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Renderer\MermaidRenderer;
6
7
use Cycle\ORM\Relation;
8
9
final class RelationMapper
10
{
11
    public const RELATIONS = [
12
        Relation::HAS_ONE => 'has_one',
13
        Relation::HAS_MANY => 'has_many',
14
        Relation::BELONGS_TO => 'belongs_to',
15
        Relation::MANY_TO_MANY => 'many_to_many',
16
        Relation::REFERS_TO => 'refers_to',
17
        Relation::MORPHED_HAS_MANY => 'morphed_has_many',
18
        Relation::MORPHED_HAS_ONE => 'morphed_has_one',
19
        Relation::BELONGS_TO_MORPHED => 'belongs_to_morphed',
20
    ];
21
22
    public function map(int $code): string
23
    {
24
        return self::RELATIONS[$code] ?? '???';
25
    }
26
}
27