HandlerTrait::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Application Class
6
 * @author Max Demian <[email protected]>
7
 */
8
9
namespace Ticaje\AliexpressConsumer\Application\UseCase\Handler;
10
11
use Ticaje\Contract\Patterns\Interfaces\Decorator\DecoratorInterface;
12
13
use Ticaje\AliexpressConsumer\Application\Interfaces\UseCaseCommandInterface;
14
15
/**
16
 * Class HandlerTrait
17
 * @package Ticaje\AliexpressConsumer\Application\UseCase\Handler
18
 */
19
trait HandlerTrait
20
{
21
    /**
22
     * @inheritDoc
23
     */
24
    public function handle(UseCaseCommandInterface $command): DecoratorInterface
25
    {
26
        $serviceRequest = $this->requestValidator->validate($command->getRequest());
27
        if ($serviceRequest->getSuccess()) {
28
            $request = [$this->mediator->getParamsWrapper() => $serviceRequest->getRequest()]; // Tiny business policy
29
            $verb = $this->verb;
30
            return $this->mediator->$verb($command->getCredentials(), $request);
31
        } else {
32
            return $serviceRequest;
33
        }
34
    }
35
}
36