WsMessageUtility   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 90
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 12
lcom 0
cbo 0
dl 30
loc 90
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A checkAnyNotEmpty() 15 15 3
A checkAllNotEmpty() 15 15 3
A checkAllIntegers() 0 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
 * WsMessageUtility - provides utility functions when constructing web service messages
27
 *
28
 * @package Amadeus\Client\Struct
29
 * @author Dieter Devlieghere <[email protected]>
30
 */
31
class WsMessageUtility
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 View Code Duplication
    protected function checkAnyNotEmpty()
0 ignored issues
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
        $foundNotEmpty = false;
42
43
        $args = func_get_args();
44
45
        foreach ($args as $arg) {
46
            if (!empty($arg)) {
47
                $foundNotEmpty = true;
48
                break;
49
            }
50
        }
51
52
        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 View Code Duplication
    protected function checkAllNotEmpty()
0 ignored issues
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
        $foundEmpty = false;
64
65
        $args = func_get_args();
66
67
        foreach ($args as $arg) {
68
            if (empty($arg)) {
69
                $foundEmpty = true;
70
                break;
71
            }
72
        }
73
74
        return !$foundEmpty;
75
    }
76
77
    /**
78
     * Check if all parameters to the current function are integers
79
     *
80
     * @param mixed
81
     * @return boolean true if all parameters are integers
82
     */
83
    protected function checkAllIntegers()
84
    {
85
        $foundNonInt = false;
86
87
        $args = func_get_args();
88
89
        foreach ($args as $arg) {
90
            if (!is_int($arg)) {
91
                $foundNonInt = true;
92
                break;
93
            }
94
        }
95
96
        return !$foundNonInt;
97
    }
98
99
    /**
100
     * Check if any parameter to the current function is true
101
     *
102
     * @param mixed
103
     * @return boolean true if at least 1 parameter is true
104
     */
105
    protected function checkAnyTrue()
106
    {
107
        $foundTrue = false;
108
109
        $args = func_get_args();
110
111
        foreach ($args as $arg) {
112
            if ($arg === true) {
113
                $foundTrue = true;
114
                break;
115
            }
116
        }
117
118
        return $foundTrue;
119
    }
120
}
121