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

RawInputParam::getValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

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