Completed
Push — master ( 8f168b...4b1795 )
by Dieter
09:49
created

BaseWsMessage   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 68
Duplicated Lines 44.12 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 30
loc 68
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkAnyNotEmpty() 15 15 3
A checkAllNotEmpty() 15 15 3
A checkAnyTrue() 0 15 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * amadeus-ws-client
4
 *
5
 * Copyright 2015 Amadeus Benelux NV
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 * http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 *
19
 * @package Amadeus
20
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
21
 */
22
23
namespace Amadeus\Client\Struct;
24
25
/**
26
 * BaseWsMessage Base Web Service message class
27
 *
28
 * @package Amadeus\Client\Struct
29
 * @author Dieter Devlieghere <[email protected]>
30
 */
31
class BaseWsMessage
32
{
33
    /**
34
     * Check if any parameter to the current function is not empty
35
     *
36
     * @param mixed
37
     * @return boolean true if at least 1 parameter is not empty
38
     */
39 38 View Code Duplication
    protected function checkAnyNotEmpty()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41 38
        $foundNotEmpty = false;
42
43 38
        $args = func_get_args();
44
45 38
        foreach ($args as $arg) {
46 38
            if (!empty($arg)) {
47 18
                $foundNotEmpty = true;
48 18
                break;
49
            }
50 38
        }
51
52 38
        return $foundNotEmpty;
53
    }
54
55
    /**
56
     * Check if all parameters to the current function are not empty
57
     *
58
     * @param mixed
59
     * @return boolean true if all parameters are not empty
60
     */
61 8 View Code Duplication
    protected function checkAllNotEmpty()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
    {
63 8
        $foundEmpty = false;
64
65 8
        $args = func_get_args();
66
67 8
        foreach ($args as $arg) {
68 8
            if (empty($arg)) {
69 4
                $foundEmpty = true;
70 4
                break;
71
            }
72 8
        }
73
74 8
        return !$foundEmpty;
75
    }
76
77
    /**
78
     * Check if any parameter to the current function is true
79
     *
80
     * @param mixed
81
     * @return boolean true if at least 1 parameter is true
82
     */
83 5
    protected function checkAnyTrue()
84
    {
85 5
        $foundTrue = false;
86
87 5
        $args = func_get_args();
88
89 5
        foreach ($args as $arg) {
90 5
            if ($arg === true) {
91 2
                $foundTrue = true;
92 2
                break;
93
            }
94 5
        }
95
96 5
        return $foundTrue;
97
    }
98
}
99