Completed
Push — master ( 5d8274...535412 )
by Elf
03:21
created

Sex   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 48
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A string() 0 8 3
A type() 0 10 3
A allTypes() 0 4 1
1
<?php
2
3
namespace ElfSundae\Laravel\Support\Constants;
4
5
class Sex
6
{
7
    const UNKNOWN = 0;
8
    const MALE = 1;
9
    const FEMALE = 2;
10
11
    /**
12
     * Convert a sex constants to string.
13
     *
14
     * @param  int  $sex
15
     * @return string|null
16
     */
17
    public static function string($sex)
18
    {
19
        if ($sex === static::MALE) {
20
            return '男';
21
        } elseif ($sex === static::FEMALE) {
22
            return '女';
23
        }
24
    }
25
26
    /**
27
     * Convert a sex string to int type.
28
     *
29
     * @param  mixed  $string
0 ignored issues
show
Bug introduced by
There is no parameter named $string. 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...
30
     * @return int
31
     */
32
    public static function type($sex)
33
    {
34
        if ($sex == '男') {
35
            return static::MALE;
36
        } elseif ($sex == '女') {
37
            return static::FEMALE;
38
        }
39
40
        return static::UNKNOWN;
41
    }
42
43
    /**
44
     * All sex types.
45
     *
46
     * @return int[]
47
     */
48
    public static function allTypes()
49
    {
50
        return [static::MALE, static::FEMALE];
51
    }
52
}
53