ArticlesTagAction   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 5 1
A validates() 0 13 2
A execute() 0 4 1
A action() 0 4 1
1
<?php
2
/**
3
 * Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
4
 *
5
 * Licensed under The MIT License
6
 * Redistributions of files must retain the above copyright notice.
7
 *
8
 * @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
9
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
10
 */
11
12
namespace CakeDC\Api\Test\App\Service\Action;
13
14
use CakeDC\Api\Exception\ValidationException;
15
use CakeDC\Api\Service\Action\CrudAction;
16
use Cake\Http\Exception\NotImplementedException;
17
use Cake\Validation\Validator;
18
19
class ArticlesTagAction extends CrudAction
20
{
21
22
    public function initialize(array $config)
23
    {
24
        parent::initialize($config);
25
        $this->Auth->allow($this->getName());
26
    }
27
28
    /**
29
     * Apply validation process.
30
     *
31
     * @return bool
32
     */
33
    public function validates()
34
    {
35
        $validator = new Validator();
36
        $validator
0 ignored issues
show
Deprecated Code introduced by
The method Cake\Validation\Validator::notEmpty() has been deprecated with message: 3.7.0 Use notEmptyString(), notEmptyArray(), notEmptyFile(), notEmptyDate(), notEmptyTime() or notEmptyDateTime() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
37
            ->requirePresence('tag_id', 'create')
38
            ->notEmpty('tag_id');
39
        $errors = $validator->errors($this->getData());
0 ignored issues
show
Deprecated Code introduced by
The method Cake\Validation\Validator::errors() has been deprecated with message: 3.9.0 Renamed to validate()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
40
        if (!empty($errors)) {
41
            throw new ValidationException(__('Validation failed'), 0, null, $errors);
42
        }
43
44
        return true;
45
    }
46
47
    public function execute()
48
    {
49
        throw new NotImplementedException('It will never thrown as action is defined');
50
    }
51
52
    /**
53
     * Execute action.
54
     *
55
     * @param int $tag_id the tag id
56
     * @return mixed
57
     */
58
    // @codingStandardsIgnoreStart
59
    public function action($tag_id)
0 ignored issues
show
Unused Code introduced by
The parameter $tag_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
    {
61
        return true;
62
    }
63
}
64