Passed
Push — master ( bf2aee...a6dc35 )
by Thierry
02:22
created

SessionTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerSessions() 0 5 1
A getSessionManager() 0 3 1
A setSessionManager() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Di\Traits;
4
5
use Closure;
6
use Jaxon\Session\SessionInterface;
7
use Jaxon\Session\SessionManager;
8
9
trait SessionTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait SessionTrait
Loading history...
10
{
11
    /**
12
     * Register the values into the container
13
     *
14
     * @return void
15
     */
16
    private function registerSessions()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
17
    {
18
        // Set the default session manager
19
        $this->set(SessionInterface::class, function() {
0 ignored issues
show
Bug introduced by
It seems like set() 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

19
        $this->/** @scrutinizer ignore-call */ 
20
               set(SessionInterface::class, function() {
Loading history...
20
            return new SessionManager();
21
        });
22
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
23
24
    /**
25
     * Get the session manager
26
     *
27
     * @return SessionInterface
28
     */
29
    public function getSessionManager(): SessionInterface
30
    {
31
        return $this->g(SessionInterface::class);
0 ignored issues
show
Bug introduced by
It seems like g() 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

31
        return $this->/** @scrutinizer ignore-call */ g(SessionInterface::class);
Loading history...
32
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
33
34
    /**
35
     * Set the session manager
36
     *
37
     * @param Closure $xClosure    A closure to create the session manager instance
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
38
     *
39
     * @return void
40
     */
41
    public function setSessionManager(Closure $xClosure)
42
    {
43
        $this->set(SessionInterface::class, $xClosure);
44
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
45
}
46