Passed
Pull Request — master (#10)
by Carlos
04:40
created

SingleRecord::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace roaresearch\yii2\roa\urlRules;
4
5
/**
6
 * Rule for routing resources which will only handle a record per authorized
7
 * user or globally in the sistem.
8
 *
9
 * That means the resource doesn't contain collections.
10
 *
11
 * @author Angel (Faryshta) Guevara <[email protected]>
12
 */
13
class SingleRecord extends Resource
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public $patterns = [
19
        'PUT,PATCH' => 'update',
20
        'DELETE' => 'delete',
21
        'GET,HEAD' => 'view',
22
        'POST' => 'create',
23
        '' => 'options',
24
    ];
25
26
    /**
27
     * @var string[] list of valid extensions that this rule can handle.
28
     */
29
    public $ext = ['png', 'jpg'];
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function init()
35
    {
36
        $this->tokens['{ext}'] = '<ext:(' . implode('|', $this->ext) . ')>';
37
        parent::init();
38
    }
39
}
40