Test Failed
Push — master ( ebe86f...4efdc4 )
by mcfog
02:46
created

BoltAbstractAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 37.5%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 29
ccs 3
cts 8
cp 0.375
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A events() 0 4 1
A injectResponseFactory() 0 5 1
A context() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Bolt;
6
7
use Lit\Air\Injection\SetterInjector;
8
use Lit\Bolt\Middlewares\EventsHub;
9
use Lit\Bolt\Middlewares\RequestContext;
10
use Lit\Voltage\AbstractAction;
11
use Psr\Http\Message\ResponseFactoryInterface;
12
13
/**
14
 * Base action class for bolt
15
 *
16
 * It's strongly recommended to have your own action base class extending this one
17
 */
18
abstract class BoltAbstractAction extends AbstractAction
19
{
20
    public const SETTER_INJECTOR = SetterInjector::class;
21
22
    /**
23
     * Injector for ResponseFactory
24
     *
25
     * @param ResponseFactoryInterface $responseFactory The ResponseFactory.
26
     * @return $this
27
     */
28 1
    public function injectResponseFactory(ResponseFactoryInterface $responseFactory): BoltAbstractAction
29
    {
30 1
        $this->responseFactory = $responseFactory;
31
32 1
        return $this;
33
    }
34
35
    /**
36
     * @deprecated
37
     */
38
    protected function events(): EventsHub
39
    {
40
        @trigger_error('EventsHub is deprecated', E_USER_DEPRECATED);
41
        return EventsHub::fromRequest($this->request);
42
    }
43
44
    protected function context(): RequestContext
45
    {
46
        return RequestContext::fromRequest($this->request);
47
    }
48
}
49