Completed
Push — master ( a02c71...2e63f9 )
by Peter
10:01
created

ImageMetaAnalyzer::analyze()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 1
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
    public function analyze($filename)
20
    {
21
        if (file_exists($filename) && ($info = @getimagesize($filename))) {
22
            return new ImageMetadata($info[0], $info[1], $info['mime']);
23
        } else {
24
            return null;
25
        }
26
    }
27
}
28