File   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 28
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
1
<?php
2
3
namespace roaresearch\yii2\roa\urlRules;
4
5
/**
6
 * Rule for routing response streams to access a file for download or view it
7
 * on browser.
8
 *
9
 * @author Angel (Faryshta) Guevara <[email protected]>
10
 */
11
class File extends Resource
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public $patterns = [
17
        'PUT,PATCH,POST {id}' => 'update',
18
        'DELETE {id}' => 'delete',
19
        'GET,HEAD {id}' => 'view',
20
        'POST' => 'create',
21
        'GET,HEAD' => 'index',
22
        '{id}' => 'options',
23
        'GET {id}.{ext}' => 'file-stream',
24
        '' => 'options',
25
    ];
26
27
    /**
28
     * @var string[] list of valid extensions that this rule can handle.
29
     */
30
    public array $ext = ['png', 'jpg'];
31
32
    /**
33
     * @inheritdoc
34
     */
35 20
    public function init()
36
    {
37 20
        $this->tokens['{ext}'] = '<ext:(' . implode('|', $this->ext) . ')>';
38 20
        parent::init();
39
    }
40
}
41