math.php ➔ max()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 0
dl 7
loc 7
rs 10
c 0
b 0
f 0
1
<?php namespace Tarsana\Functional;
2
/**
3
 * Basic Math functions.
4
 * @file
5
 */
6
7
/**
8
 * Computes `$x + $y`.
9
 *
10
 * ```php
11
 * $plusTwo = F\plus(2);
12
 * $plusTwo(5); //=> 7
13
 * ```
14
 *
15
 * @stream
16
 * @signature Number -> Number -> Number
17
 * @param  int|float $x
0 ignored issues
show
Bug introduced by
There is no parameter named $x. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
18
 * @param  int|float $y
0 ignored issues
show
Bug introduced by
There is no parameter named $y. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
19
 * @return int|float
20
 */
21 View Code Duplication
function plus() {
0 ignored issues
show
Duplication introduced by
This function 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...
22
    static $plus = false;
23
    $plus = $plus ?: curry(function($x, $y){
24
        return $x + $y;
25
    });
26
    return _apply($plus, func_get_args());
27
}
28
29
/**
30
 * Computues `$x - $y`.
31
 *
32
 * ```php
33
 * F\minus(7, 2); //=> 5
34
 * ```
35
 *
36
 * @stream
37
 * @signature Number -> Number -> Number
38
 * @param  int|float $x
0 ignored issues
show
Bug introduced by
There is no parameter named $x. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
39
 * @param  int|float $y
0 ignored issues
show
Bug introduced by
There is no parameter named $y. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
40
 * @return int|float
41
 */
42 View Code Duplication
function minus() {
0 ignored issues
show
Duplication introduced by
This function 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...
43
    static $minus = false;
44
    $minus = $minus ?: curry(function($x, $y){
45
        return $x - $y;
46
    });
47
    return _apply($minus, func_get_args());
48
}
49
50
/**
51
 * Computes `- $x`.
52
 *
53
 * ```php
54
 * F\negate(5); //=> -5
55
 * F\negate(-7); //=> 7
56
 * ```
57
 *
58
 * @stream
59
 * @signature Number -> Number
60
 * @param  int|float $x
0 ignored issues
show
Bug introduced by
There is no parameter named $x. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
61
 * @return int|float
62
 */
63 View Code Duplication
function negate() {
0 ignored issues
show
Duplication introduced by
This function 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...
64
    static $negate = false;
65
    $negate = $negate ?: curry(function($x){
66
        return -$x;
67
    });
68
    return _apply($negate, func_get_args());
69
}
70
71
/**
72
 * Computes `$x * $y`.
73
 *
74
 * ```php
75
 * $double = F\multiply(2);
76
 * $double(5); //=> 10
77
 * ```
78
 *
79
 * @stream
80
 * @signature Number -> Number -> Number
81
 * @param  int|float $x
0 ignored issues
show
Bug introduced by
There is no parameter named $x. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
82
 * @param  int|float $y
0 ignored issues
show
Bug introduced by
There is no parameter named $y. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
83
 * @return int|float
84
 */
85 View Code Duplication
function multiply() {
0 ignored issues
show
Duplication introduced by
This function 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...
86
    static $multiply = false;
87
    $multiply = $multiply ?: curry(function($x, $y){
88
        return $y * $x;
89
    });
90
    return _apply($multiply, func_get_args());
91
}
92
93
/**
94
 * Computes `$x / $y`.
95
 *
96
 * ```php
97
 * F\divide(10, 2); //=> 5
98
 * ```
99
 *
100
 * @stream
101
 * @signature Number -> Number -> Number
102
 * @param  int|float $x
0 ignored issues
show
Bug introduced by
There is no parameter named $x. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
103
 * @param  int|float $y
0 ignored issues
show
Bug introduced by
There is no parameter named $y. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
104
 * @return int|float
105
 */
106 View Code Duplication
function divide() {
0 ignored issues
show
Duplication introduced by
This function 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...
107
    static $divide = false;
108
    $divide = $divide ?: curry(function($x, $y){
109
        return $x / $y;
110
    });
111
    return _apply($divide, func_get_args());
112
}
113
114
/**
115
 * Computes `$x % $y`.
116
 *
117
 * ```php
118
 * F\modulo(10, 3); //=> 1
119
 * ```
120
 *
121
 * @stream
122
 * @signature Number -> Number -> Number
123
 * @param  int|float $x
0 ignored issues
show
Bug introduced by
There is no parameter named $x. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
124
 * @param  int|float $y
0 ignored issues
show
Bug introduced by
There is no parameter named $y. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
125
 * @return int|float
126
 */
127 View Code Duplication
function modulo() {
0 ignored issues
show
Duplication introduced by
This function 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...
128
    static $modulo = false;
129
    $modulo = $modulo ?: curry(function($x, $y){
130
        return $x % $y;
131
    });
132
    return _apply($modulo, func_get_args());
133
}
134
135
/**
136
 * Computes the sum of an array of numbers.
137
 *
138
 * ```php
139
 * F\sum([1, 2, 3, 4]); //=> 10
140
 * F\sum([]); //=> 0
141
 * ```
142
 *
143
 * @stream
144
 * @signature [Number] -> Number
145
 * @param  array $numbers
0 ignored issues
show
Bug introduced by
There is no parameter named $numbers. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
146
 * @return int|float
147
 */
148
function sum() {
149
    static $sum = false;
150
    $sum = $sum ?: curry('array_sum');
151
    return _apply($sum, func_get_args());
152
}
153
154
/**
155
 * Computes the product of an array of numbers.
156
 *
157
 * ```php
158
 * F\product([1, 2, 3, 4]); //=> 24
159
 * F\product([]); //=> 1
160
 * ```
161
 *
162
 * @stream
163
 * @signature [Number] -> Number
164
 * @param  array $numbers
0 ignored issues
show
Bug introduced by
There is no parameter named $numbers. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
165
 * @return int|float
166
 */
167
function product() {
168
    static $product = false;
169
    $product = $product ?: curry('array_product');
170
    return _apply($product, func_get_args());
171
}
172
173
/**
174
 * Computes the minimum of two numbers.
175
 *
176
 * ```php
177
 * F\min(1, 3); //=> 1
178
 * F\min(1, -3); //=> -3
179
 * ```
180
 *
181
 * @stream
182
 * @signature Number -> Number -> Number
183
 * @param  number $a
0 ignored issues
show
Bug introduced by
There is no parameter named $a. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
184
 * @param  number $b
0 ignored issues
show
Bug introduced by
There is no parameter named $b. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
185
 * @return number
186
 */
187 View Code Duplication
function min() {
0 ignored issues
show
Duplication introduced by
This function 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...
188
    static $min = false;
189
    $min = $min ?: curry(function($a, $b){
190
        return $a < $b ? $a : $b;
191
    });
192
    return _apply($min, func_get_args());
193
}
194
195
/**
196
 * Computes the minimum of two elements using a function.
197
 *
198
 * ```php
199
 * F\minBy(F\length(), 'Hello', 'Hi'); //=> 'Hi'
200
 * F\minBy('abs', 1, -3); //=> 1
201
 * ```
202
 *
203
 * @stream
204
 * @signature (a -> Number) -> a -> a -> a
205
 * @param  callable $fn
0 ignored issues
show
Bug introduced by
There is no parameter named $fn. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
206
 * @param  mixed $a
0 ignored issues
show
Bug introduced by
There is no parameter named $a. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
207
 * @param  mixed $b
0 ignored issues
show
Bug introduced by
There is no parameter named $b. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
208
 * @return mixed
209
 */
210 View Code Duplication
function minBy() {
0 ignored issues
show
Duplication introduced by
This function 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...
211
    static $minBy = false;
212
    $minBy = $minBy ?: curry(function($fn, $a, $b){
213
        return $fn($a) < $fn($b) ? $a : $b;
214
    });
215
    return _apply($minBy, func_get_args());
216
}
217
218
/**
219
 * Computes the maximum of two numbers.
220
 *
221
 * ```php
222
 * F\max(1, 3); //=> 3
223
 * F\max(1, -3); //=> 1
224
 * ```
225
 *
226
 * @stream
227
 * @signature Number -> Number -> Number
228
 * @param  number $a
0 ignored issues
show
Bug introduced by
There is no parameter named $a. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
229
 * @param  number $b
0 ignored issues
show
Bug introduced by
There is no parameter named $b. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
230
 * @return number
231
 */
232 View Code Duplication
function max() {
0 ignored issues
show
Duplication introduced by
This function 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...
233
    static $max = false;
234
    $max = $max ?: curry(function($a, $b){
235
        return $a > $b ? $a : $b;
236
    });
237
    return _apply($max, func_get_args());
238
}
239
240
/**
241
 * Computes the maximum of two elements using a function.
242
 *
243
 * ```php
244
 * F\maxBy(F\length(), 'Hello', 'Hi'); //=> 'Hello'
245
 * F\maxBy('abs', 1, -3); //=> -3
246
 * ```
247
 *
248
 * @stream
249
 * @signature (a -> Number) -> a -> a -> a
250
 * @param  callable $fn
0 ignored issues
show
Bug introduced by
There is no parameter named $fn. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
251
 * @param  mixed $a
0 ignored issues
show
Bug introduced by
There is no parameter named $a. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
252
 * @param  mixed $b
0 ignored issues
show
Bug introduced by
There is no parameter named $b. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
253
 * @return mixed
254
 */
255
function maxBy() {
256
    static $maxBy = false;
257
    $maxBy = $maxBy ?: curry(function($fn, $a, $b){
258
        return $fn($a) > $fn($b) ? $a : $b;
259
    });
260
    return _apply($maxBy, func_get_args());
261
}
262