PasetoPackage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
ccs 9
cts 9
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A addToContainer() 0 14 2
1
<?php declare(strict_types=1);
2
3
namespace Bone\Paseto;
4
5
use Barnacle\Container;
6
use Barnacle\Exception\NotFoundException;
7
use Barnacle\RegistrationInterface;
8
use ParagonIE\Paseto\Keys\SymmetricKey;
9
10
class PasetoPackage implements RegistrationInterface
11
{
12
    /**
13
     * @param Container $c
14
     */
15 3
    public function addToContainer(Container $c)
16
    {
17 3
        if (!$c->has('bone-paseto')) {
18 1
            throw new NotFoundException('Please add a bone-paseto array config with a key `sharedKey`');
19
        }
20
21 2
        $config = $c->get('bone-paseto');
22 2
        $sharedKey = $config['sharedKey'];
23 2
        $c[SymmetricKey::class] = new SymmetricKey($sharedKey);
24
25 2
        $c[PasetoService::class] = $c->factory(function (Container $c) {
26 2
            $key = $c->get(SymmetricKey::class);
27
28 2
            return new PasetoService($key);
29
        });
30
    }
31
}
32