Completed
Pull Request — master (#61)
by Michal
02:15
created

RawInputParam   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setMulti() 0 4 1
A getValue() 0 4 2
A addFormInput() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tomaj\NetteApi\Params;
6
7
use Exception;
8
use Nette\Application\UI\Form;
9
use Nette\Forms\Controls\BaseControl;
10
11
class RawInputParam extends InputParam
12
{
13
    protected $type = self::TYPE_POST_RAW;
14
15 3
    public function setMulti(): InputParam
16
    {
17 3
        throw new Exception('Cannot use multi raw input param');
18
    }
19
20 3
    public function getValue()
21
    {
22 3
        return file_get_contents("php://input") ?: $this->default;
23
    }
24
25 3
    protected function addFormInput(Form $form, string $key): BaseControl
26
    {
27 3
        return $form->addTextArea('post_raw', $this->getParamLabel())
28 3
            ->setHtmlAttribute('rows', 10);
29
    }
30
}
31