Passed
Push — master ( fcc86f...3fa4e6 )
by Laurens
01:26
created

Nfc::requiresAuthentication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\ApplePassbook\MetaData;
6
7
class Nfc
8
{
9
    private string $encryptionPublicKey;
10
    private string $message;
11
    private bool $requiresAuthentication = false;
12
13
    public function __construct(string $encryptionPublicKey, string $message)
14
    {
15
        $this->encryptionPublicKey = $encryptionPublicKey;
16
        $this->message = $message;
17
    }
18
19
    public function requireAuthentication(): void
20
    {
21
        $this->requiresAuthentication = true;
22
    }
23
24
    public function requiresAuthentication(): bool
25
    {
26
        return $this->requiresAuthentication;
27
    }
28
29
    /**
30
     * @return array<string, string|true>
31
     */
32
    public function toArray(): array
33
    {
34
        $data = [
35
            'encryptionPublicKey' => $this->encryptionPublicKey,
36
            'message' => $this->message,
37
        ];
38
39
        if ($this->requiresAuthentication) {
40
            $data['requiresAuthentication'] = $this->requiresAuthentication;
41
        }
42
43
        return $data;
44
    }
45
}
46