Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Validation\Rules;
4
 
5
use Illuminate\Support\Traits\Conditionable;
6
 
7
class Dimensions
8
{
9
    use Conditionable;
10
 
11
    /**
12
     * The constraints for the dimensions rule.
13
     *
14
     * @var array
15
     */
16
    protected $constraints = [];
17
 
18
    /**
19
     * Create a new dimensions rule instance.
20
     *
21
     * @param  array  $constraints
22
     * @return void
23
     */
24
    public function __construct(array $constraints = [])
25
    {
26
        $this->constraints = $constraints;
27
    }
28
 
29
    /**
30
     * Set the "width" constraint.
31
     *
32
     * @param  int  $value
33
     * @return $this
34
     */
35
    public function width($value)
36
    {
37
        $this->constraints['width'] = $value;
38
 
39
        return $this;
40
    }
41
 
42
    /**
43
     * Set the "height" constraint.
44
     *
45
     * @param  int  $value
46
     * @return $this
47
     */
48
    public function height($value)
49
    {
50
        $this->constraints['height'] = $value;
51
 
52
        return $this;
53
    }
54
 
55
    /**
56
     * Set the "min width" constraint.
57
     *
58
     * @param  int  $value
59
     * @return $this
60
     */
61
    public function minWidth($value)
62
    {
63
        $this->constraints['min_width'] = $value;
64
 
65
        return $this;
66
    }
67
 
68
    /**
69
     * Set the "min height" constraint.
70
     *
71
     * @param  int  $value
72
     * @return $this
73
     */
74
    public function minHeight($value)
75
    {
76
        $this->constraints['min_height'] = $value;
77
 
78
        return $this;
79
    }
80
 
81
    /**
82
     * Set the "max width" constraint.
83
     *
84
     * @param  int  $value
85
     * @return $this
86
     */
87
    public function maxWidth($value)
88
    {
89
        $this->constraints['max_width'] = $value;
90
 
91
        return $this;
92
    }
93
 
94
    /**
95
     * Set the "max height" constraint.
96
     *
97
     * @param  int  $value
98
     * @return $this
99
     */
100
    public function maxHeight($value)
101
    {
102
        $this->constraints['max_height'] = $value;
103
 
104
        return $this;
105
    }
106
 
107
    /**
108
     * Set the "ratio" constraint.
109
     *
110
     * @param  float  $value
111
     * @return $this
112
     */
113
    public function ratio($value)
114
    {
115
        $this->constraints['ratio'] = $value;
116
 
117
        return $this;
118
    }
119
 
120
    /**
121
     * Convert the rule to a validation string.
122
     *
123
     * @return string
124
     */
125
    public function __toString()
126
    {
127
        $result = '';
128
 
129
        foreach ($this->constraints as $key => $value) {
130
            $result .= "$key=$value,";
131
        }
132
 
133
        return 'dimensions:'.substr($result, 0, -1);
134
    }
135
}