Completed
Branch develop (c03385)
by Schlaefer
04:24
created

CakeLogEntry::type()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Saito - The Threaded Web Forum
7
 *
8
 * @copyright Copyright (c) the Saito Project Developers
9
 * @link https://github.com/Schlaefer/Saito
10
 * @license http://opensource.org/licenses/MIT
11
 */
12
13
namespace Admin;
14
15
/**
16
 * @bogus the ability to see logs isn't in Saito 5 anymore; see also AdminHelper::formatCakeLog
17
 */
18
class CakeLogEntry
19
{
20
    /**
21
     * Constructor
22
     *
23
     * @param string $text log entry text
24
     */
25
    public function __construct($text)
26
    {
27
        $lines = explode("\n", trim($text));
28
        $_firstLine = array_shift($lines);
29
        preg_match(
30
            '/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (.*?): (.*)/',
31
            $_firstLine,
32
            $matches
33
        );
34
        $this->_time = $matches[1];
0 ignored issues
show
Bug introduced by
The property _time does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
35
        $this->_type = $matches[2];
0 ignored issues
show
Bug introduced by
The property _type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
36
        $this->_message = trim($matches[3]);
0 ignored issues
show
Bug introduced by
The property _message does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
        if (empty($this->_message)) {
38
            $this->_message = array_shift($lines);
39
        }
40
        $this->_detail = implode($lines, '<br>');
0 ignored issues
show
Bug introduced by
The property _detail does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
41
    }
42
43
    /**
44
     * Gets log entry time
45
     *
46
     * @return string
47
     */
48
    public function time()
49
    {
50
        return $this->_time;
51
    }
52
53
    /**
54
     * Gets log entry type
55
     *
56
     * @return string
57
     */
58
    public function type()
59
    {
60
        return $this->_type;
61
    }
62
63
    /**
64
     * Gets log entry message
65
     *
66
     * @return string
67
     */
68
    public function message()
69
    {
70
        return $this->_message;
71
    }
72
73
    /**
74
     * Gets log entry details
75
     *
76
     * @return string
77
     */
78
    public function details()
79
    {
80
        return $this->_detail;
81
    }
82
}
83