Completed
Pull Request — master (#61)
by Tomas
02:14
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
namespace Tomaj\NetteApi\Params;
4
5
use Exception;
6
use Nette\Application\UI\Form;
7
use Nette\Forms\Controls\BaseControl;
8
9
class RawInputParam extends InputParam
10
{
11
    protected $type = self::TYPE_POST_RAW;
12
13 3
    public function setMulti(): InputParam
14
    {
15 3
        throw new Exception('Cannot use multi raw input param');
16
    }
17
18 3
    public function getValue()
19
    {
20 3
        return file_get_contents("php://input") ?: $this->default;
21
    }
22
23 3
    protected function addFormInput(Form $form, string $key): BaseControl
24
    {
25 3
        return $form->addTextArea('post_raw', $this->getParamLabel())
26 3
            ->setHtmlAttribute('rows', 10);
27
    }
28
}
29