Passed
Branch master (d88b3b)
by Prateek
03:56
created

SingleType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 25
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasSelfParent() 0 2 2
A getColumnKey() 0 3 1
A getValidationRule() 0 2 1
1
<?php
2
namespace Prateekkarki\Laragen\Models\Types\Relational;
3
use Prateekkarki\Laragen\Models\Types\RelationalType;
4
5
class SingleType extends RelationalType
6
{
7
    protected $dataType = 'integer';
8
    protected $hasSingleRelation = true;
9
    protected $size = false;
10
    protected $relationalType = false;
11
	protected $formType = 'parent';
12
    
13
    protected $stubs = [
14
        'modelMethod' => 'common/Models/fragments/hasOne',
15
        'foreignMethod' => 'common/Models/fragments/belongsTo'
16
    ];
17
18
    
19
    public function getValidationRule() {
20
        return 'exists:'.$this->getRelatedModule().',id';
21
    }
22
23
    public function hasSelfParent(){
24
        return ($this->typeOption == $this->getParentModule() || $this->typeOption == "self");
25
    }
26
27
    public function getColumnKey()
28
    {
29
        return $this->columnName . "_id";
30
    }
31
32
}
33