Completed
Push — watchdog-config ( 593fab )
by Frédéric G.
8s
created

Event::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 14
rs 9.4285
1
<?php
2
3
namespace Drupal\mongodb_watchdog;
4
5
use MongoDB\BSON\Unserializable;
6
7
/**
8
 * Class Event.
9
 *
10
 * @package Drupal\mongodb_watchdog
11
 */
12
class Event implements Unserializable {
13
  const KEYS = [
14
    '_id',
15
    'hostname',
16
    'link',
17
    'location',
18
    'message',
19
    'referrer',
20
    'severity',
21
    'timestamp',
22
    'type',
23
    'uid',
24
    'variables',
25
  ];
26
27
  // @codingStandardsIgnoreStart
28
  /**
29
   * The string representation of a MongoId.
30
   *
31
   * @var int
32
   */
33
  public $_id;
34
  // @codingStandardsIgnoreEnd
35
36
  /**
37
   * User id.
38
   *
39
   * @var int
40
   */
41
  public $uid;
42
43
  /**
44
   * Event type, often a module name.
45
   *
46
   * @var string
47
   */
48
  public $type;
49
50
  /**
51
   * Event template.
52
   *
53
   * @var string
54
   */
55
  public $message;
56
57
  /**
58
   * The template parameters.
59
   *
60
   * @var array
61
   */
62
  public $variables;
63
64
  /**
65
   * A RFC5424 severity level.
66
   *
67
   * @var int
68
   */
69
  public $severity;
70
71
  /**
72
   * A link provided by the event emitter. Optional.
73
   *
74
   * @var string
75
   */
76
  public $link;
77
78
  /**
79
   * The absolute URL for the path on which the event was logged.
80
   *
81
   * @var string
82
   */
83
  public $location;
84
85
  /**
86
   * A HTTP referrer for the path on which the event was logged. Optional.
87
   *
88
   * @var string
89
   */
90
  public $referrer;
91
92
  /**
93
   * The server host.
94
   *
95
   * @var string
96
   */
97
  public $hostname;
98
99
  /**
100
   * The timestamp at which the event was logged.
101
   *
102
   * @var int
103
   */
104
  public $timestamp;
105
106
  /**
107
   * Constructor.
108
   *
109
   * @param array $event
110
   *   The event in array form.
111
   */
112
  public function __construct(array $event) {
113
    $this->bsonUnserialize($event);
114
  }
115
116
  /**
117
   * {@inheritdoc}
118
   */
119
  public function bsonUnserialize(array $data) {
120
    foreach (static::KEYS as $key) {
121
      if (isset($data[$key])) {
122
        $this->{$key} = $data[$key];
123
      }
124
    }
125
  }
126
127
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
128