Completed
Push — development ( daed94...13a157 )
by Thomas
18s
created

LogType::guess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Oc\FieldNotes\Enum;
4
5
use Oc\GeoCache\Enum\LogType as GeoCacheLogType;
6
7
/**
8
 * Class LogType
9
 *
10
 * @package Oc\FieldNotes\Enum
0 ignored issues
show
introduced by
Unexpected tag type @package in doc block
Loading history...
11
 */
12
class LogType
13
{
14
    /**
15
     * @var int
16
     */
17
    const FOUND = GeoCacheLogType::FOUND;
18
19
    /**
20
     * @var int
21
     */
22
    const NOT_FOUND = GeoCacheLogType::NOT_FOUND;
23
24
    /**
25
     * @var int
26
     */
27
    const NOTE = GeoCacheLogType::NOTE;
28
29
    /**
30
     * @var int
31
     */
32
    const NEEDS_MAINTENANCE = 1000;
33
34
35
    const FILE_LOG_TYPE_MAPPING = [
36
        'Found it' => self::FOUND,
37
        "Didn't find it" => self::NOT_FOUND,
38
        'Write note' => self::NOTE,
39
        'Needs Maintenance' => self::NEEDS_MAINTENANCE
40
    ];
41
42
    /**
43
     * Guesses the log type by the string representation provided by a field note file.
44
     *
45
     * @param string $fileLogType
46
     *
47
     * @return int|null
48
     */
49
    public static function guess($fileLogType)
50
    {
51
        $logType = null;
52
53
        if (array_key_exists($fileLogType, self::FILE_LOG_TYPE_MAPPING)) {
54
            $logType = self::FILE_LOG_TYPE_MAPPING[$fileLogType];
55
        }
56
57
        return $logType;
58
    }
59
}
60