Completed
Push — master ( fe6838...baec05 )
by Ievgen
02:20
created

CRUDTraits   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 9 2
A checkPermissions() 0 6 2
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