ResponseRetrieverExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 2
A setRetriever() 0 4 1
A getRetriever() 0 4 1
1
<?php
2
3
namespace whm\Smoke\Extensions\SmokeResponseRetriever;
4
5
use phm\HttpWebdriverClient\Http\Client\HttpClient;
6
use phmLabs\Components\Annovent\Dispatcher;
7
use phmLabs\Components\Annovent\Event\Event;
8
use PhmLabs\Components\Init\Init;
9
use whm\Smoke\Config\Configuration;
10
use whm\Smoke\Extensions\SmokeResponseRetriever\Retriever\Retriever;
11
12
class ResponseRetrieverExtension
13
{
14
    /**
15
     * @var Retriever
16
     */
17
    private $retriever;
18
19
    public function init(Configuration $_configuration, Dispatcher $_eventDispatcher)
20
    {
21
        if ($_configuration->hasSection('responseRetriever')) {
22
            $this->retriever = Init::initialize($_configuration->getSection('responseRetriever'));
23
24
            $_eventDispatcher->notify(new Event('ResponseRetriever.setSessionContainer.before', array('sessionContainer' => $_configuration->getSessionContainer())));
25
26
            $this->retriever->setSessionContainer($_configuration->getSessionContainer());
27
        } else {
28
            throw new \RuntimeException("No response retriever set. Please check the config file if a section 'responseRetriever' exists.");
29
        }
30
    }
31
32
    /**
33
     * @Event("Scanner.Init")
34
     */
35
    public function setRetriever(HttpClient $httpClient)
36
    {
37
        $this->retriever->setHttpClient($httpClient);
38
    }
39
40
    public function getRetriever()
41
    {
42
        return $this->retriever;
43
    }
44
}
45