createFromHttpRequest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Tkotosz\CommandScheduler\Request\Factory;
4
5
use Tkotosz\CommandScheduler\Request\CreateCommandScheduleRequest;
6
use Magento\Framework\App\RequestInterface;
7
8
class CreateCommandScheduleRequestFactory
9
{
10
    public function createFromHttpRequest(RequestInterface $request)
11
    {
12
        $params = $request->getParams();
13
14
        if (empty($params['command_name'])) {
15
            throw new \InvalidArgumentException('missing required param: command_name');
16
        }
17
18
        return new CreateCommandScheduleRequest(
19
            $params['command_name'],
20
            $params['command_params'] ?? []
21
        );
22
    }
23
}
24