Task   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
wmc 1
lcom 0
cbo 4
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validators() 0 11 1
1
<?php
2
3
namespace Machdas\Model;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Respect\Validation\Validator;
7
8
/**
9
 * @property int     $id
10
 * @property string  $name
11
 * @property boolean $isDone
12
 * @property string  $priority
13
 * @property int     $cardId
14
 */
15
class Task extends Model
16
{
17
18
    /**
19
     * @return Validator[]
20
     */
21
    public static function validators() : array
22
    {
23
        return [
24
            'name'     => Validator::stringType()->notEmpty()->setName('name'),
25
            'isDone'   => Validator::boolType()->setName('isDone'),
26
            'priority' => Validator::intType()->between(1, 999)->setName('priority'),
27
            'cardId'   => Validator::intType()->notEmpty()->callback(function ($v) {
28
                return Card::query()->find($v) instanceof Card;
29
            })->setName('cardId')
30
        ];
31
    }
32
33
    /**
34
     * @var array
35
     */
36
    protected $casts = [
37
        'isDone' => 'boolean',
38
    ];
39
40
    /**
41
     * @var string
42
     */
43
    protected $table = 'tasks';
44
45
    /**
46
     * @var bool
47
     */
48
    public $timestamps = false;
49
}
50