2020 */
2121class VideoValidator extends FileValidator
2222{
23- /**
24- * @return void
25- */
2623 public function validate (mixed $ value , Constraint $ constraint ): void
2724 {
2825 if (!$ constraint instanceof Video) {
2926 throw new UnexpectedTypeException ($ constraint , Video::class);
3027 }
3128
32- if (!\ class_exists ('FFMpeg\FFProbe ' )) {
29+ if (!class_exists ('FFMpeg\FFProbe ' )) {
3330 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". ' );
3431 }
3532
@@ -55,7 +52,7 @@ public function validate(mixed $value, Constraint $constraint): void
5552 $ ffprobe = \FFMpeg \FFProbe::create ();
5653 $ stream = $ ffprobe ->streams ($ value )->videos ()->first ();
5754 if (!$ stream ) {
58- throw new \Exception ('Unexpected FFMpeg error ' );
55+ throw new \Exception ('Unexpected FFMpeg error. ' );
5956 }
6057 $ dimensions = $ stream ->getDimensions ();
6158 } catch (\Exception $ e ) {
@@ -72,7 +69,7 @@ public function validate(mixed $value, Constraint $constraint): void
7269
7370 if ($ constraint ->minWidth ) {
7471 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 ));
7673 }
7774
7875 if ($ width < $ constraint ->minWidth ) {
@@ -88,7 +85,7 @@ public function validate(mixed $value, Constraint $constraint): void
8885
8986 if ($ constraint ->maxWidth ) {
9087 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 ));
9289 }
9390
9491 if ($ width > $ constraint ->maxWidth ) {
@@ -104,7 +101,7 @@ public function validate(mixed $value, Constraint $constraint): void
104101
105102 if ($ constraint ->minHeight ) {
106103 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 ));
108105 }
109106
110107 if ($ height < $ constraint ->minHeight ) {
@@ -120,7 +117,7 @@ public function validate(mixed $value, Constraint $constraint): void
120117
121118 if ($ constraint ->maxHeight ) {
122119 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 ));
124121 }
125122
126123 if ($ height > $ constraint ->maxHeight ) {
@@ -136,7 +133,7 @@ public function validate(mixed $value, Constraint $constraint): void
136133
137134 if (null !== $ constraint ->minPixels ) {
138135 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 ));
140137 }
141138
142139 if ($ pixels < $ constraint ->minPixels ) {
@@ -152,7 +149,7 @@ public function validate(mixed $value, Constraint $constraint): void
152149
153150 if (null !== $ constraint ->maxPixels ) {
154151 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 ));
156153 }
157154
158155 if ($ pixels > $ constraint ->maxPixels ) {
@@ -170,7 +167,7 @@ public function validate(mixed $value, Constraint $constraint): void
170167
171168 if (null !== $ constraint ->minRatio ) {
172169 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 ));
174171 }
175172
176173 if ($ ratio < round ($ constraint ->minRatio , 2 )) {
@@ -184,7 +181,7 @@ public function validate(mixed $value, Constraint $constraint): void
184181
185182 if (null !== $ constraint ->maxRatio ) {
186183 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 ));
188185 }
189186
190187 if ($ ratio > round ($ constraint ->maxRatio , 2 )) {
0 commit comments