SSOStateStore::getOneByNameIDSessionIndex()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
rs 9.4286
cc 1
eloc 7
nc 1
nop 4
1
<?php
2
3
namespace AerialShip\SamlSPBundle\Doctrine;
4
5
use AerialShip\SamlSPBundle\Model\SSOState;
6
use AerialShip\SamlSPBundle\State\SSO\AbstractSSOStateStore;
7
use AerialShip\SamlSPBundle\State\SSO\SSOStateStoreInterface;
8
use Doctrine\Common\Persistence\ObjectManager;
9
10
/**
11
 * @api
12
 */
13
class SSOStateStore extends AbstractSSOStateStore
14
{
15
    /** @var ObjectManager  */
16
    protected $objectManager;
17
18
    /**
19
     * @param ObjectManager $objectManager
20
     * @param string        $entityClass
21
     */
22
    public function __construct(ObjectManager $objectManager, $entityClass)
23
    {
24
        parent::__construct($entityClass);
25
26
        $this->objectManager = $objectManager;
27
    }
28
29
    /**
30
     * @param SSOState $state
31
     *
32
     * @return void
33
     */
34
    public function set(SSOState $state)
35
    {
36
        $this->objectManager->persist($state);
37
        $this->objectManager->flush();
38
    }
39
40
    /**
41
     * @param string $providerID
42
     * @param string $authenticationServiceName
43
     * @param string $nameID
44
     *
45
     * @return SSOState[]
46
     */
47
    public function getAllByNameID($providerID, $authenticationServiceName, $nameID)
48
    {
49
        return $this->getRepository()->findBy(
50
            array(
51
                'providerID' => $providerID,
52
                'authenticationServiceName' => $authenticationServiceName,
53
                'nameID' => $nameID
54
            )
55
        );
56
    }
57
58
    /**
59
     * @param string $providerID
60
     * @param string $authenticationServiceName
61
     * @param string $nameID
62
     * @param string $sessionIndex
63
     * @return SSOState
64
     */
65
    public function getOneByNameIDSessionIndex($providerID, $authenticationServiceName, $nameID, $sessionIndex)
66
    {
67
        return $this->getRepository()->findOneBy(
68
            array(
69
                'providerID' => $providerID,
70
                'authenticationServiceName' => $authenticationServiceName,
71
                'nameID' => $nameID,
72
                'sessionIndex' => $sessionIndex
73
            )
74
        );
75
    }
76
77
    /**
78
     * @param SSOState $state
79
     *
80
     * @return void
81
     */
82
    public function remove(SSOState $state)
83
    {
84
        $this->objectManager->remove($state);
85
        $this->objectManager->flush();
86
    }
87
88
    /**
89
     * @return \Doctrine\Common\Persistence\ObjectRepository
90
     */
91
    protected function getRepository()
92
    {
93
        return $this->objectManager->getRepository($this->entityClass);
94
    }
95
}
96