ResponseFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Dwr\OpenWeather\Factory;
4
5
class ResponseFactory
6
{
7
    const RESPONSE_NAMESPACE = 'Dwr\\OpenWeather\\Response\\';
8
9
    /**
10
     * @var string
11
     */
12
    private $responseClass;
13
14
    /**
15
     * ResponseFactory constructor.
16
     * @param string $responseType
17
     */
18
    public function __construct($responseType)
19
    {
20
        $this->responseClass = self::RESPONSE_NAMESPACE . $responseType;
21
    }
22
23
    /**
24
     * @param array $data
25
     * @return mixed
26
     */
27
    public function create($data)
28
    {
29
        return new $this->responseClass(json_decode($data, true));
30
    }
31
}