Passed
Pull Request — master (#20)
by Hilmi Erdem
10:06
created

GenericFormat::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 3
1
<?php
2
/*
3
 * Copyright (c) 2021. Hilmi Erdem Keren
4
 * license MIT
5
 */
6
7
namespace Erdemkeren\Otp;
8
9
use Closure;
10
use Erdemkeren\Otp\Contracts\FormatContract;
11
12
class GenericFormat implements FormatContract
13
{
14
    public function __construct(
15
        private string $name,
16
        private Closure $generator,
17
        private Closure $notificationResolver
18
    ) {
19
    }
20
21
    public function name(): string
22
    {
23
        return $this->name;
24
    }
25
26
    public function generator(): Closure
27
    {
28
        return $this->generator;
29
    }
30
31
    public function createNotification(OtpToken $token): object
32
    {
33
        return ($this->notificationResolver)($token);
34
    }
35
}
36