Completed
Push — master ( f62226...8b6b73 )
by Stéphane
10s
created

HasCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A commandsRequest() 0 4 1
A commandsPost() 0 4 1
1
<?php
2
/**
3
 * This file is part of the bee4/transport package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2015
8
 * @author  Stephane HULARD <[email protected]>
9
 * @package Bee4\Transport\Configuration
10
 */
11
12
namespace Bee4\Transport\Configuration;
13
14
/**
15
 * Trait to handle commands property
16
 * @package Bee4\Transport\Configuration
17
 */
18
trait HasCommand
19
{
20
    /**
21
     * Define which command must be ran with the request
22
     * @param mixed $command Command to be ran before actual request is performed
23
     * @return Configuration|mixed
24
     */
25
    public function commandsRequest($command = null)
26
    {
27
        return $this->arrayValue('commands', 'request', $command);
0 ignored issues
show
Bug introduced by
It seems like arrayValue() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
28
    }
29
30
    /**
31
     * Define which command must be ran after the request
32
     * @param mixed $command Command to be ran after actual request is performed
33
     * @return Configuration|mixed
34
     */
35
    public function commandsPost($command = null)
36
    {
37
        return $this->arrayValue('commands', 'post', $command);
0 ignored issues
show
Bug introduced by
It seems like arrayValue() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
38
    }
39
}
40