7
7
/**
8
8
* @file classes/citation/Citation.php
9
9
*
10
- * Copyright (c) 2014-2021 Simon Fraser University
11
- * Copyright (c) 2000-2021 John Willinsky
10
+ * Copyright (c) 2014-2024 Simon Fraser University
11
+ * Copyright (c) 2000-2024 John Willinsky
12
12
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
13
13
*
14
14
* @class Citation
20
20
21
21
namespace PKP \citation ;
22
22
23
- class Citation extends \PKP \core \DataObject
23
+ use PKP \core \DataObject ;
24
+
25
+ class Citation extends DataObject
24
26
{
25
27
/**
26
28
* Constructor.
27
29
*
28
- * @param string $rawCitation an unparsed citation string
30
+ * @param string|null $rawCitation an unparsed citation string
29
31
*/
30
- public function __construct ($ rawCitation = null )
32
+ public function __construct (string $ rawCitation = null )
31
33
{
32
34
parent ::__construct ();
33
35
$ this ->setRawCitation ($ rawCitation );
34
36
}
35
37
36
- //
37
- // Getters and Setters
38
- //
38
+ /**
39
+ * Get publication id.
40
+ */
41
+ public function getPublicationId ()
42
+ {
43
+ return $ this ->getData ('publicationId ' );
44
+ }
39
45
40
46
/**
41
- * Replace URLs through HTML links, if the citation does not already contain HTML links
42
- *
43
- * @return string
47
+ * Replace URLs through HTML links, if the citation does not already contain HTML links.
44
48
*/
45
- public function getCitationWithLinks ()
49
+ public function getCitationWithLinks (): string
46
50
{
47
51
$ citation = $ this ->getRawCitation ();
48
52
if (stripos ($ citation , '<a href= ' ) === false ) {
@@ -60,51 +64,42 @@ function ($matches) {
60
64
}
61
65
62
66
/**
63
- * Get the rawCitation
64
- *
65
- * @return string
67
+ * Get the rawCitation.
66
68
*/
67
- public function getRawCitation ()
69
+ public function getRawCitation (): string
68
70
{
69
71
return $ this ->getData ('rawCitation ' );
70
72
}
71
73
72
74
/**
73
- * Set the rawCitation
75
+ * Set the rawCitation.
74
76
*/
75
- public function setRawCitation (?string $ rawCitation )
77
+ public function setRawCitation (?string $ rawCitation ): void
76
78
{
77
79
$ rawCitation = $ this ->_cleanCitationString ($ rawCitation ?? '' );
78
80
$ this ->setData ('rawCitation ' , $ rawCitation );
79
81
}
80
82
81
83
/**
82
84
* Get the sequence number
83
- *
84
- * @return int
85
85
*/
86
- public function getSequence ()
86
+ public function getSequence (): int
87
87
{
88
88
return $ this ->getData ('seq ' );
89
89
}
90
90
91
91
/**
92
92
* Set the sequence number
93
- *
94
- * @param int $seq
95
93
*/
96
- public function setSequence ($ seq )
94
+ public function setSequence (int $ seq ): void
97
95
{
98
96
$ this ->setData ('seq ' , $ seq );
99
97
}
100
98
101
- //
102
- // Private methods
103
- //
104
99
/**
105
100
* Take a citation string and clean/normalize it
106
101
*/
107
- public function _cleanCitationString (string $ citationString) : string
102
+ private function cleanCitationString (string $ citationString = null ) : string
108
103
{
109
104
// 1) Strip slashes and whitespace
110
105
$ citationString = trim (stripslashes ($ citationString ));
0 commit comments