AuditLogModel::getStatus()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Craft;
4
5
/**
6
 * Audit Log Model.
7
 *
8
 * Contains the log data aswell as some constants
9
 *
10
 * @author    Bob Olde Hampsink <[email protected]>
11
 * @copyright Copyright (c) 2015, Bob Olde Hampsink
12
 * @license   MIT
13
 *
14
 * @link      http://github.com/boboldehampsink
15
 */
16
class AuditLogModel extends BaseElementModel
17
{
18
    /**
19
     * Statuses.
20
     */
21
    const CREATED   = 'live';
22
    const MODIFIED  = 'pending';
23
    const DELETED   = 'expired';
24
25
    /**
26
     * Fieldtypes.
27
     */
28
    const FieldTypeEntries     = 'Entries';
29
    const FieldTypeCategories  = 'Categories';
30
    const FieldTypeAssets      = 'Assets';
31
    const FieldTypeUsers       = 'Users';
32
    const FieldTypeLightswitch = 'Lightswitch';
33
34
    /**
35
     * Element Type name.
36
     *
37
     * @var string
38
     */
39
    protected $elementType = 'AuditLog';
40
41
    /**
42
     * Return the title of this model.
43
     *
44
     * @return string
45
     */
46
    public function getTitle()
47
    {
48
        return $this->type;
49
    }
50
51
    /**
52
     * Return the model's attributes.
53
     *
54
     * @return array
55
     */
56
    protected function defineAttributes()
57
    {
58
        return array_merge(parent::defineAttributes(), array(
59
            'id'        => AttributeType::Number,
60
            'type'      => AttributeType::String,
61
            'userId'    => AttributeType::Number,
62
            'origin'    => AttributeType::String,
63
            'before'    => AttributeType::Mixed,
64
            'after'     => AttributeType::Mixed,
65
            'diff'      => AttributeType::Mixed,
66
            'status'    => AttributeType::String,
67
        ));
68
    }
69
70
    /**
71
     * Return the model's status.
72
     *
73
     * @return string
74
     */
75
    public function getStatus()
76
    {
77
        return $this->status;
78
    }
79
80
    /**
81
     * Return the model's user.
82
     *
83
     * @return UserModel
84
     */
85
    public function getUser()
86
    {
87
        return craft()->users->getUserById($this->userId);
88
    }
89
}
90