20
20
*/
21
21
class VideoValidator extends FileValidator
22
22
{
23
- /**
24
- * @return void
25
- */
26
23
public function validate (mixed $ value , Constraint $ constraint ): void
27
24
{
28
25
if (!$ constraint instanceof Video) {
29
26
throw new UnexpectedTypeException ($ constraint , Video::class);
30
27
}
31
28
32
- if (!\ class_exists ('FFMpeg\FFProbe ' )) {
29
+ if (!class_exists ('FFMpeg\FFProbe ' )) {
33
30
throw new \LogicException ('The "php-ffmpeg/php-ffmpeg" library must be installed to use the Video constraint. Try running "composer require php-ffmpeg/php-ffmpeg". ' );
34
31
}
35
32
@@ -55,7 +52,7 @@ public function validate(mixed $value, Constraint $constraint): void
55
52
$ ffprobe = \FFMpeg \FFProbe::create ();
56
53
$ stream = $ ffprobe ->streams ($ value )->videos ()->first ();
57
54
if (!$ stream ) {
58
- throw new \Exception ('Unexpected FFMpeg error ' );
55
+ throw new \Exception ('Unexpected FFMpeg error. ' );
59
56
}
60
57
$ dimensions = $ stream ->getDimensions ();
61
58
} catch (\Exception $ e ) {
@@ -72,7 +69,7 @@ public function validate(mixed $value, Constraint $constraint): void
72
69
73
70
if ($ constraint ->minWidth ) {
74
71
if (!ctype_digit ((string ) $ constraint ->minWidth )) {
75
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid minimum width. ' , $ constraint ->minWidth ));
72
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid minimum width. ' , $ constraint ->minWidth ));
76
73
}
77
74
78
75
if ($ width < $ constraint ->minWidth ) {
@@ -88,7 +85,7 @@ public function validate(mixed $value, Constraint $constraint): void
88
85
89
86
if ($ constraint ->maxWidth ) {
90
87
if (!ctype_digit ((string ) $ constraint ->maxWidth )) {
91
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid maximum width. ' , $ constraint ->maxWidth ));
88
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid maximum width. ' , $ constraint ->maxWidth ));
92
89
}
93
90
94
91
if ($ width > $ constraint ->maxWidth ) {
@@ -104,7 +101,7 @@ public function validate(mixed $value, Constraint $constraint): void
104
101
105
102
if ($ constraint ->minHeight ) {
106
103
if (!ctype_digit ((string ) $ constraint ->minHeight )) {
107
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid minimum height. ' , $ constraint ->minHeight ));
104
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid minimum height. ' , $ constraint ->minHeight ));
108
105
}
109
106
110
107
if ($ height < $ constraint ->minHeight ) {
@@ -120,7 +117,7 @@ public function validate(mixed $value, Constraint $constraint): void
120
117
121
118
if ($ constraint ->maxHeight ) {
122
119
if (!ctype_digit ((string ) $ constraint ->maxHeight )) {
123
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid maximum height. ' , $ constraint ->maxHeight ));
120
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid maximum height. ' , $ constraint ->maxHeight ));
124
121
}
125
122
126
123
if ($ height > $ constraint ->maxHeight ) {
@@ -136,7 +133,7 @@ public function validate(mixed $value, Constraint $constraint): void
136
133
137
134
if (null !== $ constraint ->minPixels ) {
138
135
if (!ctype_digit ((string ) $ constraint ->minPixels )) {
139
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid minimum amount of pixels. ' , $ constraint ->minPixels ));
136
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid minimum amount of pixels. ' , $ constraint ->minPixels ));
140
137
}
141
138
142
139
if ($ pixels < $ constraint ->minPixels ) {
@@ -152,7 +149,7 @@ public function validate(mixed $value, Constraint $constraint): void
152
149
153
150
if (null !== $ constraint ->maxPixels ) {
154
151
if (!ctype_digit ((string ) $ constraint ->maxPixels )) {
155
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid maximum amount of pixels. ' , $ constraint ->maxPixels ));
152
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid maximum amount of pixels. ' , $ constraint ->maxPixels ));
156
153
}
157
154
158
155
if ($ pixels > $ constraint ->maxPixels ) {
@@ -170,7 +167,7 @@ public function validate(mixed $value, Constraint $constraint): void
170
167
171
168
if (null !== $ constraint ->minRatio ) {
172
169
if (!is_numeric ((string ) $ constraint ->minRatio )) {
173
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid minimum ratio. ' , $ constraint ->minRatio ));
170
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid minimum ratio. ' , $ constraint ->minRatio ));
174
171
}
175
172
176
173
if ($ ratio < round ($ constraint ->minRatio , 2 )) {
@@ -184,7 +181,7 @@ public function validate(mixed $value, Constraint $constraint): void
184
181
185
182
if (null !== $ constraint ->maxRatio ) {
186
183
if (!is_numeric ((string ) $ constraint ->maxRatio )) {
187
- throw new ConstraintDefinitionException (sprintf ('"%s" is not a valid maximum ratio. ' , $ constraint ->maxRatio ));
184
+ throw new ConstraintDefinitionException (\ sprintf ('"%s" is not a valid maximum ratio. ' , $ constraint ->maxRatio ));
188
185
}
189
186
190
187
if ($ ratio > round ($ constraint ->maxRatio , 2 )) {
0 commit comments