Passed
Pull Request — master (#9)
by Csaba
02:38
created

FooSchema::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace Fathomminds\Rest\Examples\Clusterpoint\Models\Schema;
3
4
use Fathomminds\Rest\Schema\SchemaValidator;
5
use Fathomminds\Rest\Schema\TypeValidators\StringValidator;
6
use Fathomminds\Rest\Schema\TypeValidators\IntegerValidator;
7
use Fathomminds\Rest\Helpers\Uuid;
8
9
class FooSchema extends SchemaValidator
10
{
11
    protected $fields = [
12
        '_id' => [
13
            'unique' => true,
14
            'validator' => [
15
                'class' => StringValidator::class,
16
            ]
17
        ],
18
        'title' => [
19
            'unique' => true,
20
            'required' => true,
21
            'validator' => [
22
                'class' => StringValidator::class,
23
                'params' => [
24
                    'maxLength' => 100,
25
                ],
26
            ],
27
        ],
28
        'status' => [
29
            'default' => 0,
30
            'validator' => [
31
                'class' => IntegerValidator::class,
32
                'params' => [
33
                    'min' => 0,
34
                    'max' => 1,
35
                ],
36
            ],
37
        ],
38
        'bar' => [
39
            'type' => BarSchema::class,
40
        ],
41
    ];
42
43
    public function __construct()
44
    {
45
        $this->setDefault('_id', function () {
46
            return (new Uuid)->generate();
47
        });
48
    }
49
}
50