JsonApiDataRulesSerializerInterface
last analyzed

Size/Duplication

Total Lines 155
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 155
c 0
b 0
f 0

19 Methods

Rating   Name   Duplication   Size   Complexity  
addRulesFromClass() 0 1 ?
addDataRules() 0 8 ?
getData() 0 1 ?
readBlocks() 0 1 ?
hasRules() 0 1 ?
readRules() 0 1 ?
readIdRuleIndexes() 0 1 ?
readTypeRuleIndexes() 0 1 ?
readAttributeRulesIndexes() 0 1 ?
readToOneRulesIndexes() 0 1 ?
readToManyRulesIndexes() 0 1 ?
readRuleIndex() 0 1 ?
readRuleStartIndexes() 0 1 ?
readRuleEndIndexes() 0 1 ?
readRulesIndexes() 0 1 ?
readRulesStartIndexes() 0 1 ?
readRulesEndIndexes() 0 1 ?
readSingleRuleIndexes() 0 1 ?
hasRule() 0 1 ?
1
<?php declare (strict_types = 1);
2
3
namespace Limoncello\Flute\Contracts\Validation;
4
5
/**
6
 * Copyright 2015-2019 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Limoncello\Validation\Contracts\Rules\RuleInterface;
22
23
/**
24
 * @package Limoncello\Application
25
 */
26
interface JsonApiDataRulesSerializerInterface
27
{
28
    /**
29
     * Add rules from data rules class.
30
     *
31
     * @param string $rulesClass
32
     *
33
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
34
     */
35
    public function addRulesFromClass(string $rulesClass): self;
36
37
    /**
38
     * Add rules manually.
39
     *
40
     * @param string          $name
41
     * @param RuleInterface   $idRule
42
     * @param RuleInterface   $typeRule
43
     * @param RuleInterface[] $attributeRules
44
     * @param RuleInterface[] $toOneRules
45
     * @param RuleInterface[] $toManyRules
46
     *
47
     * @return self
48
     */
49
    public function addDataRules(
50
        string $name,
51
        RuleInterface $idRule,
52
        RuleInterface $typeRule,
53
        array $attributeRules,
54
        array $toOneRules,
55
        array $toManyRules
56
    ): JsonApiDataRulesSerializerInterface;
57
58
    /**
59
     * Get serialized data.
60
     *
61
     * @return array
62
     */
63
    public function getData(): array;
64
65
    /**
66
     * @param array $serializedData
67
     *
68
     * @return array
69
     */
70
    public static function readBlocks(array $serializedData): array;
71
72
    /**
73
     * @param string $name
74
     * @param array  $serializedData
75
     *
76
     * @return bool
77
     */
78
    public static function hasRules(string $name, array $serializedData): bool;
79
80
    /**
81
     * @param string $rulesClass
82
     * @param array  $serializedData
83
     *
84
     * @return array
85
     */
86
    public static function readRules(string $rulesClass, array $serializedData): array;
87
88
    /**
89
     * @param array $serializedRules
90
     *
91
     * @return array
92
     */
93
    public static function readIdRuleIndexes(array $serializedRules): array;
94
95
    /**
96
     * @param array $serializedRules
97
     *
98
     * @return array
99
     */
100
    public static function readTypeRuleIndexes(array $serializedRules): array;
101
102
    /**
103
     * @param array $serializedRules
104
     *
105
     * @return array
106
     */
107
    public static function readAttributeRulesIndexes(array $serializedRules): array;
108
109
    /**
110
     * @param array $serializedRules
111
     *
112
     * @return array
113
     */
114
    public static function readToOneRulesIndexes(array $serializedRules): array;
115
116
    /**
117
     * @param array $serializedRules
118
     *
119
     * @return array
120
     */
121
    public static function readToManyRulesIndexes(array $serializedRules): array;
122
123
    /**
124
     * @param array $ruleIndexes
125
     *
126
     * @return int
127
     */
128
    public static function readRuleIndex(array $ruleIndexes): int;
129
130
    /**
131
     * @param array $ruleIndexes
132
     *
133
     * @return array
134
     */
135
    public static function readRuleStartIndexes(array $ruleIndexes): array;
136
137
    /**
138
     * @param array $ruleIndexes
139
     *
140
     * @return array
141
     */
142
    public static function readRuleEndIndexes(array $ruleIndexes): array;
143
144
    /**
145
     * @param array $arrayRuleIndexes
146
     *
147
     * @return array
148
     */
149
    public static function readRulesIndexes(array $arrayRuleIndexes): array;
150
151
    /**
152
     * @param array $arrayRuleIndexes
153
     *
154
     * @return array
155
     */
156
    public static function readRulesStartIndexes(array $arrayRuleIndexes): array;
157
158
    /**
159
     * @param array $arrayRuleIndexes
160
     *
161
     * @return array
162
     */
163
    public static function readRulesEndIndexes(array $arrayRuleIndexes): array;
164
165
    /**
166
     * @param array  $arrayRuleIndexes
167
     * @param string $name
168
     *
169
     * @return array
170
     */
171
    public static function readSingleRuleIndexes(array $arrayRuleIndexes, string $name): array;
172
173
    /**
174
     * @param int   $index
175
     * @param array $blocks
176
     *
177
     * @return bool
178
     */
179
    public static function hasRule(int $index, array $blocks): bool;
180
}
181