AbstractParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResponse() 0 12 2
parse() 0 1 ?
1
<?php
2
namespace Thunder\SimilarWebApi;
3
4
/**
5
 * @author Tomasz Kowalczyk <[email protected]>
6
 */
7
abstract class AbstractParser implements ParserInterface
8
    {
9
    protected $name;
10
    protected $mapping;
11
12 38
    public function __construct($name, array $mapping)
13
        {
14 38
        $this->name = $name;
15 38
        $this->mapping = $mapping;
16 38
        }
17
18 38
    public function getResponse($content)
19
        {
20 38
        $response = $this->parse($content);
21 33
        $class = 'Thunder\\SimilarWebApi\\Response\\'.$this->name;
22
23 33
        if(!class_exists($class, true))
24 33
            {
25 1
            throw new \RuntimeException(sprintf('Failed to load response class %s!', $class));
26
            }
27
28 32
        return new $class($response);
29
        }
30
31
    abstract protected function parse($content);
32
    }
33