Passed
Push — main ( ec913c...6eea45 )
by Peter
07:00 queued 02:38
created

DeckManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 17
ccs 0
cts 7
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrCreateDeck() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
namespace App\Service;
4
5
use App\Card\Deck;
6
use Symfony\Component\HttpFoundation\Session\SessionInterface;
7
8
class DeckManager
9
{
10
    private SessionInterface $session;
11
12
    public function __construct(SessionInterface $session)
13
    {
14
        $this->session = $session;
15
    }
16
17
    public function getOrCreateDeck(): Deck
18
    {
19
        if (!$this->session->has('deck')) {
20
            $deck = new Deck();
21
            $this->session->set('deck', $deck);
22
        }
23
24
        return $this->session->get('deck');
25
    }
26
}
27