Passed
Push — drivers ( 5f8646...aadeb1 )
by Joe
01:53
created

Payload   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 9
c 0
b 0
f 0
dl 0
loc 28
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A exists() 0 3 1
A get() 0 7 2
A doesNotExist() 0 3 1
A add() 0 5 1
1
<?php
2
3
namespace PhpWinTools\WmiScripting\Support\Events;
4
5
class Payload
6
{
7
    protected $context = [];
8
9
    public function add($key, $value)
10
    {
11
        $this->context[$key] = $value;
12
13
        return $this;
14
    }
15
16
    public function get($key, $default = null)
17
    {
18
        if ($this->doesNotExist($key)) {
19
            return $default;
20
        }
21
22
        return $this->context[$key] ?? $default;
23
    }
24
25
    public function exists($key)
26
    {
27
        return array_key_exists($key, $this->context);
28
    }
29
30
    public function doesNotExist($key)
31
    {
32
        return $this->exists($key) === false;
33
    }
34
}
35