Passed
Push — master ( 1d7587...a5dfb5 )
by Gabriel
02:49
created

CryptKeysTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 9
c 1
b 0
f 1
dl 0
loc 32
ccs 8
cts 14
cp 0.5714
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A makeCryptKey() 0 3 1
A appendCryptKeysToProvide() 0 5 1
A registerCryptKeys() 0 7 1
1
<?php
2
3
namespace ByTIC\Hello\Oauth\ServiceProvider\Traits;
4
5
use ByTIC\Hello\Utility\ConfigHelper;
6
use ByTIC\Hello\Utility\CryptHelper;
7
use League\OAuth2\Server\CryptKey;
8
9
/**
10
 * Trait CryptKeysTrait
11
 * @package ByTIC\Hello\Oauth\ServiceProvider\Traits
12
 */
13
trait CryptKeysTrait
14
{
15 2
    public function registerCryptKeys()
16
    {
17 2
        $this->getContainer()->share('hello.keys.private', function () {
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $this->/** @scrutinizer ignore-call */ 
18
               getContainer()->share('hello.keys.private', function () {
Loading history...
18
            return $this->makeCryptKey('private');
19 2
        });
20 2
        $this->getContainer()->share('hello.keys.public', function () {
21
            return $this->makeCryptKey('public');
22 2
        });
23 2
    }
24
25
    /**
26
     * @param $return
27
     * @return array
28
     */
29
    protected function appendCryptKeysToProvide($return)
30
    {
31
        $return[] = 'hello.keys.private';
32
        $return[] = 'hello.keys.public';
33
        return $return;
34
    }
35
36
    /**
37
     * Create a CryptKey instance without permissions check
38
     *
39
     * @param  $type
40
     * @return \League\OAuth2\Server\CryptKey
41
     */
42 1
    protected function makeCryptKey($type)
43
    {
44 1
        return CryptHelper::makeCryptKey($type);
45
    }
46
}
47