ImageMetaAnalyzer::analyze()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Component\ImageMeta;
11
12
class ImageMetaAnalyzer
13
{
14
    /**
15
     * @param string $filename
16
     *
17
     * @return ImageMetadata|null
18
     */
19 7
    public function analyze($filename)
20
    {
21 7
        if (file_exists($filename) && ($info = @getimagesize($filename))) {
22 5
            return new ImageMetadata($info[0], $info[1], $info['mime']);
23
        } else {
24 2
            return null;
25
        }
26
    }
27
}
28