Failed Conditions
Push — master ( 6560de...8483ce )
by Florent
05:17
created

KeyAnalyzerManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A analyze() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Component\KeyManagement\KeyAnalyzer;
15
16
use Jose\Component\Core\JWK;
17
18
/**
19
 * Class KeyAnalyzerManager.
20
 */
21
final class KeyAnalyzerManager
22
{
23
    /**
24
     * @var KeyAnalyzer[]
25
     */
26
    private $analyzers = [];
27
28
    /**
29
     * @param KeyAnalyzer $analyzer
30
     *
31
     * @return KeyAnalyzerManager
32
     */
33
    public function add(KeyAnalyzer $analyzer): self
34
    {
35
        $this->analyzers[] = $analyzer;
36
37
        return $this;
38
    }
39
40
    /**
41
     * @param JWK $jwk
42
     *
43
     * @return MessageBag
44
     */
45
    public function analyze(JWK $jwk): MessageBag
46
    {
47
        $bag = new MessageBag();
48
        foreach ($this->analyzers as $analyzer) {
49
            $analyzer->analyze($jwk, $bag);
50
        }
51
52
        return $bag;
53
    }
54
}
55