Completed
Push — master ( 1316ca...59eabb )
by Daniel
11:50
created

ColorProfile::fromPath()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.2
cc 4
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * This file is part of the Magickly project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Magickly\Image;
9
10
use GravityMedia\Magickly\Exception\RuntimeException;
11
12
/**
13
 * Color profile class.
14
 *
15
 * @package GravityMedia\Magickly\Image
16
 */
17
class ColorProfile
18
{
19
    /**
20
     * @var string
21
     */
22
    protected $data;
23
24
    /**
25
     * Create color profile object.
26
     *
27
     * @param string $data
28
     */
29
    public function __construct($data)
30
    {
31
        $this->data = $data;
32
    }
33
34
    /**
35
     * Get data.
36
     *
37
     * @return string
38
     */
39
    public function getData()
40
    {
41
        return $this->data;
42
    }
43
44
    /**
45
     * Create color profile object from path.
46
     *
47
     * @param string $path
48
     *
49
     * @return $this
50
     */
51
    public static function fromPath($path)
52
    {
53
        if (!file_exists($path) || !is_file($path) || !is_readable($path)) {
54
            throw new RuntimeException(sprintf('Path %s is an invalid profile file or is not readable', $path));
55
        }
56
57
        return new static(file_get_contents($path));
58
    }
59
}
60