Completed
Push — master ( 6db6da...5370d9 )
by Angel
03:42
created

ProfileResource   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 11 1
A verbs() 0 10 1
A actions() 0 8 1
1
<?php
2
3
namespace roaresearch\yii2\roa\controllers;
4
5
use roaresearch\yii2\roa\actions\{ProfileUpdate, ProfileView};
6
use yii\{filters\VerbFilter, rest\OptionsAction};
7
8
class ProfileResource extends \yii\rest\Controller
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function behaviors()
14
    {
15
        return [
16
            // content negotiator, autenticator, etc moved by default to
17
            // api container
18
            'verbFilter' => [
19
                'class' => VerbFilter::class,
20
                'actions' => $this->verbs(),
21
            ],
22
        ];
23
    }
24
25
    /**
26
     * @inheridoc
27
     */
28
    protected function verbs()
29
    {
30
        $verbs = ['GET', 'PUT', 'PATCH', 'OPTIONS'];
31
32
        return [
33
            'view' => $verbs,
34
            'update' => $verbs,
35
            'options' => $verbs,
36
        ];
37
    }
38
39
    /**
40
     * @inheridoc
41
     */
42
    public function actions()
43
    {
44
        return [
45
            'view' => ['class' => ProfileView::class],
46
            'update' => ['class' => ProfileUpdate::class],
47
            'options' => ['class' => OptionsAction::class],
48
        ];
49
    }
50
}
51