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

RelationMapper::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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