Completed
Push — 8.x-2.x ( 8af97d...4c7eae )
by Frédéric G.
03:11
created

Event::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 8
rs 9.4285
1
<?php
2
3
/**
4
 * @file
5
 * Contains MongoDb watchdog event.
6
 */
7
8
namespace Drupal\mongodb_watchdog;
9
10
/**
11
 * Class Event.
12
 *
13
 * @package Drupal\mongodb_watchdog
14
 */
15
class Event {
0 ignored issues
show
Coding Style introduced by
The property $_id is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
16
  /**
17
   * The string representation of a MongoId.
18
   *
19
   * @var int
20
   */
21
  public $_id;
0 ignored issues
show
introduced by
Class property $_id should use lowerCamel naming without underscores
Loading history...
22
23
  /**
24
   * User id.
25
   *
26
   * @var int
27
   */
28
  public $uid;
29
30
  /**
31
   * Event type, often a module name.
32
   *
33
   * @var string
34
   */
35
  public $type;
36
37
  /**
38
   * Event template.
39
   *
40
   * @var string
41
   */
42
  public $message;
43
44
  /**
45
   * The template parameters.
46
   *
47
   * @var array
48
   */
49
  public $variables;
50
51
  /**
52
   * A RFC5424 severity level.
53
   *
54
   * @var int
55
   */
56
  public $severity;
57
58
  /**
59
   * A link provided by the event emitter. Optional.
60
   *
61
   * @var string
62
   */
63
  public $link;
64
65
  /**
66
   * The absolute URL for the path on which the event was logged.
67
   *
68
   * @var string
69
   */
70
  public $location;
71
72
  /**
73
   * A HTTP referrer for the path on which the event was logged. Optional.
74
   *
75
   * @var string
76
   */
77
  public $referrer;
78
79
  /**
80
   * The server host.
81
   *
82
   * @var string
83
   */
84
  public $hostname;
85
86
  /**
87
   * The timestamp at which the event was logged.
88
   *
89
   * @var int
90
   */
91
  public $timestamp;
92
93
  /**
94
   * Constructor.
95
   *
96
   * @param array $event
97
   *   The event in array form.
98
   */
99
  public function __construct(array $event) {
100
    $keys = ['_id', 'hostname', 'link', 'location', 'message', 'referrer', 'severity', 'timestamp', 'type', 'uid', 'variables'];
101
    foreach ($keys as $key) {
102
      if (isset($event[$key])) {
103
        $this->$key = $event[$key];
104
      }
105
    }
106
  }
107
}
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...
108