Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.64% covered (warning)
63.64%
7 / 11
50.00% covered (danger)
50.00%
4 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
ExternalSession
63.64% covered (warning)
63.64%
7 / 11
50.00% covered (danger)
50.00%
4 / 8
11.08
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSessionId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setSessionId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getExternalSessionId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setExternalSessionId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getCreated
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCreated
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Row Definition for external_session
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2010.
9 * Copyright (C) The National Library of Finland 2016.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2,
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 *
24 * @category VuFind
25 * @package  Db_Row
26 * @author   Demian Katz <demian.katz@villanova.edu>
27 * @author   Ere Maijala <ere.maijala@helsinki.fi>
28 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
29 * @link     https://vufind.org Main Site
30 */
31
32namespace VuFind\Db\Row;
33
34use DateTime;
35use VuFind\Db\Entity\ExternalSessionEntityInterface;
36
37/**
38 * Row Definition for external_session
39 *
40 * @category VuFind
41 * @package  Db_Row
42 * @author   Demian Katz <demian.katz@villanova.edu>
43 * @author   Ere Maijala <ere.maijala@helsinki.fi>
44 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
45 * @link     https://vufind.org Main Site
46 *
47 * @property int    $id
48 * @property string $session_id
49 * @property string $external_session_id
50 * @property string $created
51 */
52class ExternalSession extends RowGateway implements \VuFind\Db\Entity\ExternalSessionEntityInterface
53{
54    /**
55     * Constructor
56     *
57     * @param \Laminas\Db\Adapter\Adapter $adapter Database adapter
58     */
59    public function __construct($adapter)
60    {
61        parent::__construct('id', 'external_session', $adapter);
62    }
63
64    /**
65     * Get identifier (returns null for an uninitialized or non-persisted object).
66     *
67     * @return ?int
68     */
69    public function getId(): ?int
70    {
71        return $this->id ?? null;
72    }
73
74    /**
75     * Get PHP session id string.
76     *
77     * @return string
78     */
79    public function getSessionId(): string
80    {
81        return $this->session_id ?? '';
82    }
83
84    /**
85     * Set PHP session id string.
86     *
87     * @param string $sessionId PHP session id string
88     *
89     * @return ExternalSessionEntityInterface
90     */
91    public function setSessionId(string $sessionId): ExternalSessionEntityInterface
92    {
93        $this->session_id = $sessionId;
94        return $this;
95    }
96
97    /**
98     * Get PHP external session id string.
99     *
100     * @return string
101     */
102    public function getExternalSessionId(): string
103    {
104        return $this->external_session_id ?? '';
105    }
106
107    /**
108     * Set external session id string.
109     *
110     * @param string $externalSessionId External session id string
111     *
112     * @return ExternalSessionEntityInterface
113     */
114    public function setExternalSessionId(string $externalSessionId): ExternalSessionEntityInterface
115    {
116        $this->external_session_id = $externalSessionId;
117        return $this;
118    }
119
120    /**
121     * Get created date.
122     *
123     * @return DateTime
124     */
125    public function getCreated(): DateTime
126    {
127        return DateTime::createFromFormat('Y-m-d H:i:s', $this->created);
128    }
129
130    /**
131     * Set created date.
132     *
133     * @param DateTime $dateTime Created date
134     *
135     * @return ExternalSessionEntityInterface
136     */
137    public function setCreated(DateTime $dateTime): ExternalSessionEntityInterface
138    {
139        $this->created = $dateTime->format('Y-m-d H:i:s');
140        return $this;
141    }
142}