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

BoltAbstractAction::injectResponseFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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