Passed
Push — master ( 2fd976...262699 )
by Anton
01:57
created

HasOne   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A compute() 0 8 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
namespace Cycle\Schema\Relation;
11
12
use Cycle\ORM\Relation;
13
use Cycle\Schema\Registry;
14
15
class HasOne extends AbstractSchema
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected const OPTION_SCHEMA = [
21
        // save with parent
22
        Relation::CASCADE   => true,
23
24
        // not nullable by default
25
        Relation::NULLABLE  => false,
26
27
        // use outer entity constrain by default
28
        Relation::CONSTRAIN => true,
29
30
        // link to parent entity primary key by default
31
        Relation::INNER_KEY => '{source:primaryKey}',
32
33
        // default field name for inner key
34
        Relation::OUTER_KEY => '{source:role}_{innerKey}',
35
    ];
36
37
    public function compute(Registry $registry)
38
    {
39
        parent::compute($registry);
40
41
        dump($this->options);
42
43
        dump($this->options->get(Relation::CONSTRAIN));
44
        dump($this->options->get(Relation::OUTER_KEY));
45
    }
46
}