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

ColorProfile   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getData() 0 4 1
A fromPath() 0 8 4
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