Passed
Branch feature/ide (e899a2)
by Csaba
02:33
created

FooSchema::schema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 51
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 9.4109
c 0
b 0
f 0
cc 1
eloc 33
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Fathomminds\Rest\Examples\DynamoDb\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\Examples\DynamoDb\Models\Schema\BarSchema;
8
9
/**
10
 *
11
 * @property string $_id
12
 * @property string $title
13
 * @property string $other
14
 * @property string $noindex
15
 * @property integer $status
16
 * @property BarSchema $bar
17
 *
18
 */
19
20
class FooSchema extends Schema
21
{
22
    public function schema()
23
    {
24
        return [
25
            '_id' => [
26
                'unique' => true,
27
                'validator' => [
28
                    'class' => StringValidator::class,
29
                ]
30
            ],
31
            'title' => [
32
                'unique' => true,
33
                'required' => true,
34
                'validator' => [
35
                    'class' => StringValidator::class,
36
                    'params' => [
37
                        'maxLength' => 100,
38
                    ],
39
                ],
40
            ],
41
            'other' => [
42
                'unique' => true,
43
                'validator' => [
44
                    'class' => StringValidator::class,
45
                    'params' => [
46
                        'maxLength' => 100,
47
                    ],
48
                ],
49
            ],
50
            'noindex' => [
51
                'unique' => true,
52
                'validator' => [
53
                    'class' => StringValidator::class,
54
                    'params' => [
55
                        'maxLength' => 100,
56
                    ],
57
                ],
58
            ],
59
            'status' => [
60
                'validator' => [
61
                    'class' => IntegerValidator::class,
62
                    'params' => [
63
                        'min' => 0,
64
                        'max' => 1,
65
                    ],
66
                ],
67
            ],
68
            'bar' => [
69
                'type' => BarSchema::class,
70
            ],
71
        ];
72
    }
73
}
74