Completed
Push — master ( 32257f...b97b6f )
by
unknown
05:21
created

ImageFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A defaultMap() 0 7 1
1
<?php
2
3
namespace Charcoal\Image;
4
5
// From 'charcoal-factory'
6
use \Charcoal\Factory\AbstractFactory;
7
8
/**
9
 * Create image class from image processor type.
10
 */
11
class ImageFactory extends AbstractFactory
12
{
13
    /**
14
     * @param array $data Constructor dependencies.
15
     */
16
    public function __construct(array $data = null)
17
    {
18
        if (isset($data['map'])) {
19
            $data['map'] = array_merge($this->defaultMap(), $data['map']);
20
        } else {
21
            $data['map'] = $this->defaultMap();
22
        }
23
24
        parent::__construct($data);
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    protected function defaultMap()
31
    {
32
        return [
33
            'imagick'     => '\Charcoal\Image\Imagick\ImagickImage',
34
            'imagemagick' => '\Charcoal\Image\Imagemagick\ImagemagickImage'
35
        ];
36
    }
37
}
38