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