Completed
Push — master ( 0ca994...bcdd07 )
by Neomerx
05:23
created

ExistInDatabaseTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A exists() 0 4 1
A existAll() 0 4 1
A unique() 0 4 1
1
<?php namespace Limoncello\Flute\Validation\Rules;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Validation\Contracts\Rules\RuleInterface;
20
21
/**
22
 * @package Limoncello\Flute
23
 */
24
trait ExistInDatabaseTrait
25
{
26
    /**
27
     * @param string $tableName
28
     * @param string $primaryName
29
     *
30
     * @return RuleInterface
31
     */
32
    public static function exists(string $tableName, string $primaryName): RuleInterface
33
    {
34
        return new ExistInDbTableSingleWithDoctrine($tableName, $primaryName);
35
    }
36
37
    /**
38
     * @param string $tableName
39
     * @param string $primaryName
40
     *
41
     * @return RuleInterface
42
     */
43
    public static function existAll(string $tableName, string $primaryName): RuleInterface
44
    {
45
        return new ExistInDbTableMultipleWithDoctrine($tableName, $primaryName);
46
    }
47
48
    /**
49
     * @param string $tableName
50
     * @param string $primaryName
51
     *
52
     * @return RuleInterface
53
     */
54
    public static function unique(string $tableName, string $primaryName): RuleInterface
55
    {
56
        return new UniqueInDbTableSingleWithDoctrine($tableName, $primaryName);
57
    }
58
}
59