UrlRule   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 1
1
<?php
2
/**
3
 * @author Anton Tuyakhov <[email protected]>
4
 */
5
6
namespace tuyakhov\jsonapi;
7
8
9
/**
10
 * UrlRule is provided to simplify the creation of URL rules for JSON API support.
11
 * @package tuyakhov\jsonapi
12
 */
13
class UrlRule extends \yii\rest\UrlRule
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function init()
19
    {
20
        $this->tokens = array_merge($this->tokens, array_merge([
21
            '{relationship}' => '<name:\w+>'
22
        ]));
23
        $this->patterns = array_merge($this->patterns, [
24
            'DELETE {id}/relationships/{relationship}' => 'delete-relationship',
25
            'POST,PATCH {id}/relationships/{relationship}' => 'update-relationship',
26
            'GET {id}/{relationship}' => 'view-related',
27
            '{id}/{relationship}' => 'options'
28
        ]);
29
        parent::init();
30
    }
31
32
}