ResponseFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

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