ImageValidator::extractWidthHeight()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 2
nop 1
1
<?php
2
3
/**
4
 * Copyright 2014 Jonathan Bouzekri. All rights reserved.
5
 *
6
 * @copyright Copyright 2014 Jonathan Bouzekri <[email protected]>
7
 * @license https://github.com/jbouzekri/FileUploaderBundle/blob/master/LICENSE
8
 * @link https://github.com/jbouzekri/FileUploaderBundle
9
 */
10
11
namespace Jb\Bundle\FileUploaderBundle\Service\Validator;
12
13
use Jb\Bundle\FileUploaderBundle\Exception\ValidationException;
14
15
/**
16
 * ImageValidator
17
 *
18
 * @author jobou
19
 */
20
class ImageValidator extends AbstractImageValidator
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function extractWidthHeight($value)
26
    {
27
        $size = @getimagesize($this->formatValue($value));
28
29
        if (empty($size) || ($size[0] === 0) || ($size[1] === 0)) {
30
            throw new ValidationException('Unable to determine size.');
31
        }
32
33
        return array(
34
            'width' => $size[0],
35
            'height' => $size[1]
36
        );
37
    }
38
}
39