Event   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 41
ccs 0
cts 13
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setupValidation() 0 6 1
A boot() 0 4 1
A relateDeployment() 0 4 1
1
<?php
2
3
namespace App\Model;
4
5
use App\Model\Deployment;
6
use App\Model\Finder\EventFinder;
7
use Respect\Validation\Validator;
8
use Ronanchilvers\Orm\Model;
9
use Ronanchilvers\Orm\Traits\HasValidationTrait;
10
11
/**
12
 * Model representing a deployment event
13
 *
14
 * @property int id
15
 * @property null|\App\Model\Deployment deployment
16
 * @property string type
17
 * @property string header
18
 * @property string detail
19
 * @property null|\Carbon\Carbon created
20
 * @property null|\Carbon\Carbon updated
21
 * @author Ronan Chilvers <[email protected]>
22
 */
23
class Event extends Model
24
{
25
    use HasValidationTrait;
26
27
    static protected $finder       = EventFinder::class;
28
    static protected $columnPrefix = 'event';
29
30
    /**
31
     * Boot the model
32
     *
33
     * @author Ronan Chilvers <[email protected]>
34
     */
35
    protected function boot()
36
    {
37
        $this->addType('model', 'deployment', [
38
            'class' => Deployment::class
39
        ]);
40
    }
41
42
    /**
43
     * @author Ronan Chilvers <[email protected]>
44
     */
45
    protected function setupValidation()
46
    {
47
        $this->registerRules([
48
            'deployment' => Validator::notEmpty()->intVal()->min(1),
49
            'type'       => Validator::notEmpty(),
50
            'header'     => Validator::notEmpty(),
51
        ]);
52
    }
53
54
    /**
55
     * Relationship with project
56
     *
57
     * @return \App\Model\Deployment
58
     * @author Ronan Chilvers <[email protected]>
59
     */
60
    protected function relateDeployment()
61
    {
62
        return $this->belongsTo(
63
            Deployment::class
64
        );
65
    }
66
}
67