CRUDTraits::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
use einfach\operation\{Railway, Result};
4
use function einfach\operation\response\{ok, error};
5
6
trait CRUDTraits 
0 ignored issues
show
Coding Style Compatibility introduced by
Each trait must be in a namespace of at least one level (a top-level vendor name)

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    public function validate($params)
9
    {
10
        // pretend a lot of validations here
11
        if($params['price'] > 100) {
12
            return ok($params);
13
        } else {
14
            return error($params, 'Too cheap to be true!');
15
        }
16
    }
17
18
    public function checkPermissions($params)
19
    {
20
        return ( $params['user']->login == 'yevhen' ) 
21
                ? ok($params) 
22
                : error($params, 'Permission denied!');
23
    }
24
}
25