Passed
Push — develop ( 6779d1...bdd5c6 )
by Csaba
32s
created

FooSchema   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 41
c 0
b 0
f 0
rs 10
1
<?php
2
namespace Fathomminds\Rest\Examples\Clusterpoint\Models\Schema;
3
4
use Fathomminds\Rest\Schema;
5
use Fathomminds\Rest\Schema\TypeValidators\StringValidator;
6
use Fathomminds\Rest\Schema\TypeValidators\IntegerValidator;
7
use Fathomminds\Rest\Helpers\Uuid;
8
use Fathomminds\Rest\Examples\Clusterpoint\Models\Schema\BarSchema;
9
10
/**
11
 *
12
 * @property string $_id
13
 * @property string $title
14
 * @property integer $status
15
 * @property BarSchema $bar
16
 *
17
 */
18
19
20
class FooSchema extends Schema
21
{
22
    public function schema()
23
    {
24
        return [
25
            '_id' => [
26
                'unique' => true,
27
                'default' => function () {
28
                    return (new Uuid)->generate();
29
                },
30
                'validator' => [
31
                    'class' => StringValidator::class,
32
                ]
33
            ],
34
            'title' => [
35
                'unique' => true,
36
                'required' => true,
37
                'validator' => [
38
                    'class' => StringValidator::class,
39
                    'params' => [
40
                        'maxLength' => 100,
41
                    ],
42
                ],
43
            ],
44
            'status' => [
45
                'default' => 0,
46
                'validator' => [
47
                    'class' => IntegerValidator::class,
48
                    'params' => [
49
                        'min' => 0,
50
                        'max' => 1,
51
                    ],
52
                ],
53
            ],
54
            'bar' => [
55
                'type' => BarSchema::class,
56
            ],
57
        ];
58
    }
59
}
60