CreateCommandScheduleRequestFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromHttpRequest() 0 11 2
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