Completed
Pull Request — master (#131)
by Arnaud
35:53
created

AdminHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrent() 0 3 1
A setCurrent() 0 7 2
1
<?php
2
3
namespace LAG\AdminBundle\Admin\Helper;
4
5
use LAG\AdminBundle\Admin\AdminInterface;
6
use LAG\AdminBundle\Exception\Exception;
7
8
class AdminHelper implements AdminHelperInterface
9
{
10
    private $frozen = false;
11
12
    /**
13
     * @var AdminInterface
14
     */
15
    private $admin;
16
17
    public function setCurrent(AdminInterface $admin): void
18
    {
19
        if ($this->frozen) {
20
            throw new Exception('The current admin cannot be set twice in a request');
21
        }
22
        $this->admin = $admin;
23
        $this->frozen = true;
24
    }
25
26
    public function getCurrent(): ?AdminInterface
27
    {
28
        return $this->admin;
29
    }
30
}
31