FirebaseProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 37
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A init() 0 8 1
A get() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Piotzkhider\FirebaseModule;
6
7
use Kreait\Firebase;
8
use Kreait\Firebase\Factory;
9
use Kreait\Firebase\ServiceAccount;
10
use Piotzkhider\FirebaseModule\Annotation\Credentials;
11
use Ray\Di\Di\PostConstruct;
12
use Ray\Di\ProviderInterface;
13
14
class FirebaseProvider implements ProviderInterface
15
{
16
    /**
17
     * @var mixed
18
     */
19
    private $credentials;
20
21
    /**
22
     * @var Firebase
23
     */
24
    private $firebase;
25
26
    /**
27
     * @Credentials()
28
     */
29 5
    public function __construct($credentials)
30
    {
31 5
        $this->credentials = $credentials;
32 5
    }
33
34
    /**
35
     * @PostConstruct
36
     */
37 5
    public function init(): void
38
    {
39 5
        $serviceAccount = ServiceAccount::fromValue($this->credentials);
40
41 5
        $this->firebase = (new Factory())
42 5
            ->withServiceAccount($serviceAccount)
43 5
            ->create();
44 5
    }
45
46 5
    public function get()
47
    {
48 5
        return $this->firebase;
49
    }
50
}
51