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

GenericFormat   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 4
c 1
b 0
f 0
dl 0
loc 22
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A generator() 0 3 1
A createNotification() 0 3 1
A name() 0 3 1
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