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

Payload::doesNotExist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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