@@ -22,46 +22,46 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param string $typeid |
24 | 24 | */ |
25 | - public function __construct( $typeid = '' ) { |
|
26 | - parent::__construct( $typeid ); |
|
27 | - $this->resourceIdentifierStringValueParser = new ResourceIdentifierStringValueParser( $typeid ); |
|
25 | + public function __construct($typeid = '') { |
|
26 | + parent::__construct($typeid); |
|
27 | + $this->resourceIdentifierStringValueParser = new ResourceIdentifierStringValueParser($typeid); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @see StringValue::parseUserValue |
32 | 32 | */ |
33 | - protected function parseUserValue( $value ) { |
|
33 | + protected function parseUserValue($value) { |
|
34 | 34 | |
35 | 35 | $inputValue = $value; |
36 | 36 | // $this->m_caption = $value; |
37 | 37 | |
38 | - if ( !$this->resourceIdentifierStringValueParser->parse( $value ) ) { |
|
39 | - $this->addError( wfMessage( 'sci-datavalue-invalid-id-value', $inputValue, $this->resourceIdentifierStringValueParser->getCanonicalName() )->inContentLanguage()->escaped() ); |
|
40 | - $this->m_dataitem = new DIBlob( 'ERROR' ); |
|
38 | + if (!$this->resourceIdentifierStringValueParser->parse($value)) { |
|
39 | + $this->addError(wfMessage('sci-datavalue-invalid-id-value', $inputValue, $this->resourceIdentifierStringValueParser->getCanonicalName())->inContentLanguage()->escaped()); |
|
40 | + $this->m_dataitem = new DIBlob('ERROR'); |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - parent::parseUserValue( $value ); |
|
44 | + parent::parseUserValue($value); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @see StringValue::getShortWikiText |
49 | 49 | */ |
50 | - public function getShortWikiText( $linker = null ) { |
|
50 | + public function getShortWikiText($linker = null) { |
|
51 | 51 | |
52 | - if ( !$this->isValid() ) { |
|
52 | + if (!$this->isValid()) { |
|
53 | 53 | return ''; |
54 | 54 | } |
55 | 55 | |
56 | - if ( !$this->m_caption ) { |
|
56 | + if (!$this->m_caption) { |
|
57 | 57 | $this->m_caption = $this->m_dataitem->getString(); |
58 | 58 | } |
59 | 59 | |
60 | - if ( $preferredCaption = $this->getPreferredCaption() ) { |
|
60 | + if ($preferredCaption = $this->getPreferredCaption()) { |
|
61 | 61 | return $preferredCaption; |
62 | 62 | } |
63 | 63 | |
64 | - if ( $linker === null ) { |
|
64 | + if ($linker === null) { |
|
65 | 65 | return $this->m_caption; |
66 | 66 | } |
67 | 67 | |
@@ -70,35 +70,35 @@ discard block |
||
70 | 70 | [ |
71 | 71 | 'class' => 'plainlinks' |
72 | 72 | ], |
73 | - '[' . $this->getTargetLink( urlencode( $this->m_caption ) ) . ' ' . $this->m_caption .']' |
|
73 | + '[' . $this->getTargetLink(urlencode($this->m_caption)) . ' ' . $this->m_caption . ']' |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @see StringValue::getShortHTMLText |
79 | 79 | */ |
80 | - public function getShortHTMLText( $linker = null ) { |
|
80 | + public function getShortHTMLText($linker = null) { |
|
81 | 81 | |
82 | - if ( !$this->isValid() ) { |
|
82 | + if (!$this->isValid()) { |
|
83 | 83 | return ''; |
84 | 84 | } |
85 | 85 | |
86 | - if ( !$this->m_caption ) { |
|
86 | + if (!$this->m_caption) { |
|
87 | 87 | $this->m_caption = $this->m_dataitem->getString(); |
88 | 88 | } |
89 | 89 | |
90 | - if ( $preferredCaption = $this->getPreferredCaption() ) { |
|
90 | + if ($preferredCaption = $this->getPreferredCaption()) { |
|
91 | 91 | return $preferredCaption; |
92 | 92 | } |
93 | 93 | |
94 | - if ( $linker === null ) { |
|
94 | + if ($linker === null) { |
|
95 | 95 | return $this->m_caption; |
96 | 96 | } |
97 | 97 | |
98 | 98 | return Html::rawElement( |
99 | 99 | 'a', |
100 | 100 | [ |
101 | - 'href' => $this->getTargetLink( $this->m_caption ), |
|
101 | + 'href' => $this->getTargetLink($this->m_caption), |
|
102 | 102 | 'target' => '_blank' |
103 | 103 | ], |
104 | 104 | $this->m_caption |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @see StringValue::getLongWikiText |
110 | 110 | */ |
111 | - public function getLongWikiText( $linked = null ) { |
|
112 | - return $this->getShortWikiText( $linked ); |
|
111 | + public function getLongWikiText($linked = null) { |
|
112 | + return $this->getShortWikiText($linked); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * @see StringValue::getLongHTMLText |
117 | 117 | */ |
118 | - public function getLongHTMLText( $linker = null ) { |
|
119 | - return $this->getShortHTMLText( $linker ); |
|
118 | + public function getLongHTMLText($linker = null) { |
|
119 | + return $this->getShortHTMLText($linker); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function getPreferredCaption() { |
126 | 126 | |
127 | - if ( $this->m_outformat == '-' ) { |
|
127 | + if ($this->m_outformat == '-') { |
|
128 | 128 | return $this->m_caption; |
129 | 129 | } |
130 | 130 | |
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | |
134 | - private function getTargetLink( $target ) { |
|
134 | + private function getTargetLink($target) { |
|
135 | 135 | return $this->resourceIdentifierStringValueParser->getResourceTargetUri() . $target; |
136 | 136 | } |
137 | 137 |
@@ -23,36 +23,36 @@ |
||
23 | 23 | * @return ResourceIdentifierStringValue |
24 | 24 | * @throws RuntimeException |
25 | 25 | */ |
26 | - public function newResourceIdentifierStringValueForType( $type ) { |
|
26 | + public function newResourceIdentifierStringValueForType($type) { |
|
27 | 27 | |
28 | 28 | $propertyRegistry = PropertyRegistry::getInstance(); |
29 | 29 | $property = null; |
30 | 30 | |
31 | - switch ( strtoupper( $type ) ) { |
|
31 | + switch (strtoupper($type)) { |
|
32 | 32 | case 'OCLC': |
33 | 33 | case 'VIAF': |
34 | 34 | case 'DOI': |
35 | 35 | case 'OLID': |
36 | - $property = $propertyRegistry->findPropertyIdByLabel( $type ); |
|
36 | + $property = $propertyRegistry->findPropertyIdByLabel($type); |
|
37 | 37 | break; |
38 | 38 | case 'PUBMED': |
39 | 39 | case 'PMID': |
40 | - $property = $propertyRegistry->findPropertyIdByLabel( 'PMID' ); |
|
40 | + $property = $propertyRegistry->findPropertyIdByLabel('PMID'); |
|
41 | 41 | break; |
42 | 42 | case 'PMC': |
43 | 43 | case 'PMCID': |
44 | - $property = $propertyRegistry->findPropertyIdByLabel( 'PMCID' ); |
|
44 | + $property = $propertyRegistry->findPropertyIdByLabel('PMCID'); |
|
45 | 45 | break; |
46 | 46 | } |
47 | 47 | |
48 | - $typeId = $propertyRegistry->getPropertyTypeId( $property ); |
|
48 | + $typeId = $propertyRegistry->getPropertyTypeId($property); |
|
49 | 49 | |
50 | - if ( $typeId === null || $typeId === '' ) { |
|
51 | - throw new RuntimeException( "{$type} is an unmatched type for ResourceIdentifierStringValue" ); |
|
50 | + if ($typeId === null || $typeId === '') { |
|
51 | + throw new RuntimeException("{$type} is an unmatched type for ResourceIdentifierStringValue"); |
|
52 | 52 | } |
53 | 53 | |
54 | - $resourceIdentifierStringValue = DataValueFactory::getInstance()->newDataValueByType( $typeId ); |
|
55 | - $resourceIdentifierStringValue->setProperty( new DIProperty( $property ) ); |
|
54 | + $resourceIdentifierStringValue = DataValueFactory::getInstance()->newDataValueByType($typeId); |
|
55 | + $resourceIdentifierStringValue->setProperty(new DIProperty($property)); |
|
56 | 56 | |
57 | 57 | return $resourceIdentifierStringValue; |
58 | 58 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @param string $typeid |
20 | 20 | */ |
21 | - public function __construct( $typeid ) { |
|
21 | + public function __construct($typeid) { |
|
22 | 22 | $this->typeid = $typeid; |
23 | 23 | } |
24 | 24 | |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return true |
29 | 29 | */ |
30 | - public function parse( &$value ) { |
|
30 | + public function parse(&$value) { |
|
31 | 31 | |
32 | 32 | // Remove a possible url-prefix |
33 | 33 | |
34 | - if ( $this->typeid === '_sci_doi' ) { |
|
34 | + if ($this->typeid === '_sci_doi') { |
|
35 | 35 | // Remove anything before 10 as in http://dx.doi.org/10.1000/123 |
36 | - $value = substr( $value, strcspn( $value, '10' ) ); |
|
37 | - } elseif ( strrpos( $value, '://' ) !== false ) { |
|
36 | + $value = substr($value, strcspn($value, '10')); |
|
37 | + } elseif (strrpos($value, '://') !== false) { |
|
38 | 38 | // Remove anything before the last / as in http://foo/bar123 |
39 | - $value = substr( $value, strrpos( $value, '/' ) + 1 ); |
|
39 | + $value = substr($value, strrpos($value, '/') + 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // Remove other possible prefixes |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | // All DOI names are converted to upper case upon registration |
46 | 46 | // but since it system is case insensitive, we store it as lower |
47 | 47 | // case as it "looks" better |
48 | - if ( $this->typeid === '_sci_doi' ) { |
|
49 | - $value = strtolower( $value ); |
|
48 | + if ($this->typeid === '_sci_doi') { |
|
49 | + $value = strtolower($value); |
|
50 | 50 | } else { |
51 | - $value = str_replace( [ 'VIAF', 'OCLC', 'PMID' ], '', strtoupper( $value ) ); |
|
51 | + $value = str_replace(['VIAF', 'OCLC', 'PMID'], '', strtoupper($value)); |
|
52 | 52 | } |
53 | 53 | |
54 | - return $this->canMatchValueToPattern( $value ); |
|
54 | + return $this->canMatchValueToPattern($value); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getCanonicalName() { |
61 | 61 | |
62 | - switch ( $this->typeid ) { |
|
62 | + switch ($this->typeid) { |
|
63 | 63 | case '_sci_viaf': |
64 | 64 | return 'VIAF'; |
65 | 65 | case '_sci_oclc': |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getResourceTargetUri() { |
84 | 84 | |
85 | - switch ( $this->typeid ) { |
|
85 | + switch ($this->typeid) { |
|
86 | 86 | case '_sci_viaf': |
87 | 87 | // http://www.oclc.org/research/activities/viaf.html |
88 | 88 | // http://id.loc.gov/vocabulary/identifiers/viaf.html |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - private function canMatchValueToPattern( &$value ) { |
|
106 | + private function canMatchValueToPattern(&$value) { |
|
107 | 107 | |
108 | - switch ( $this->typeid ) { |
|
108 | + switch ($this->typeid) { |
|
109 | 109 | case '_sci_viaf': |
110 | 110 | case '_sci_oclc': |
111 | 111 | case '_sci_pmid': |
112 | - return preg_match( "/^[0-9]*$/", $value ); |
|
112 | + return preg_match("/^[0-9]*$/", $value); |
|
113 | 113 | case '_sci_pmcid': |
114 | - return preg_match( "/PMC[\d]+/", $value ); |
|
114 | + return preg_match("/PMC[\d]+/", $value); |
|
115 | 115 | case '_sci_olid': |
116 | - return preg_match( "/OL[A-Z0-9]+/", $value ); |
|
116 | + return preg_match("/OL[A-Z0-9]+/", $value); |
|
117 | 117 | case '_sci_doi': |
118 | 118 | // http://stackoverflow.com/questions/27910/finding-a-doi-in-a-document-or-page# |
119 | - return preg_match( "/\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?![\"&\'])\S)+)\b/", $value ); |
|
119 | + return preg_match("/\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?![\"&\'])\S)+)\b/", $value); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return false; |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function getFormattedSciteFuncFrom( array $parameters ) { |
|
22 | - return "<pre>{{#scite:\n" . implode( "\n", $this->format( $parameters ) ) ."\n}}</pre>"; |
|
21 | + public function getFormattedSciteFuncFrom(array $parameters) { |
|
22 | + return "<pre>{{#scite:\n" . implode("\n", $this->format($parameters)) . "\n}}</pre>"; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return array |
29 | 29 | */ |
30 | - public function format( array $parameters ) { |
|
30 | + public function format(array $parameters) { |
|
31 | 31 | |
32 | 32 | $formatted = []; |
33 | 33 | |
34 | - foreach ( $parameters as $key => $value ) { |
|
34 | + foreach ($parameters as $key => $value) { |
|
35 | 35 | |
36 | - if ( $value === '' || $value[0] === '@' ) { |
|
36 | + if ($value === '' || $value[0] === '@') { |
|
37 | 37 | continue; |
38 | 38 | } |
39 | 39 | |
40 | - if ( $value[0] === '+' ) { |
|
41 | - $formatted[$key-1] = $formatted[$key-1] . '|' . $value; |
|
40 | + if ($value[0] === '+') { |
|
41 | + $formatted[$key - 1] = $formatted[$key - 1] . '|' . $value; |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param Cache $cache |
37 | 37 | * @param CacheKeyProvider $cacheKeyProvider |
38 | 38 | */ |
39 | - public function __construct( Cache $cache, CacheKeyProvider $cacheKeyProvider ) { |
|
39 | + public function __construct(Cache $cache, CacheKeyProvider $cacheKeyProvider) { |
|
40 | 40 | $this->cache = $cache; |
41 | 41 | $this->cacheKeyProvider = $cacheKeyProvider; |
42 | 42 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return boolean |
50 | 50 | */ |
51 | - public function hasCitationReference( SemanticData $semanticData ) { |
|
52 | - return $semanticData->getPropertyValues( new DIProperty( PropertyRegistry::SCI_CITE_REFERENCE ) ) !== []; |
|
51 | + public function hasCitationReference(SemanticData $semanticData) { |
|
52 | + return $semanticData->getPropertyValues(new DIProperty(PropertyRegistry::SCI_CITE_REFERENCE)) !== []; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return array|null |
61 | 61 | */ |
62 | - public function getJournalBySubject( DIWikiPage $subject ) { |
|
63 | - return $this->hasJournalForHash( $subject->getHash() ) ? self::$citationReferenceJournal[$subject->getHash()] : null; |
|
62 | + public function getJournalBySubject(DIWikiPage $subject) { |
|
63 | + return $this->hasJournalForHash($subject->getHash()) ? self::$citationReferenceJournal[$subject->getHash()] : null; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return array|null |
76 | 76 | */ |
77 | - public function buildJournalForUnboundReferenceList( array $referenceList ) { |
|
77 | + public function buildJournalForUnboundReferenceList(array $referenceList) { |
|
78 | 78 | |
79 | - if ( $referenceList === [] ) { |
|
79 | + if ($referenceList === []) { |
|
80 | 80 | return null; |
81 | 81 | } |
82 | 82 | |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | 'reference-pos' => [] |
87 | 87 | ]; |
88 | 88 | |
89 | - $journal['total'] = count( $referenceList ); |
|
89 | + $journal['total'] = count($referenceList); |
|
90 | 90 | |
91 | - foreach ( $referenceList as $reference ) { |
|
91 | + foreach ($referenceList as $reference) { |
|
92 | 92 | $journal['reference-pos'][$reference] = []; |
93 | 93 | $journal['reference-list'][$reference] = $reference; |
94 | 94 | } |
@@ -104,22 +104,22 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return string|null |
106 | 106 | */ |
107 | - public function findLastReferencePositionEntryFor( DIWikiPage $subject = null, $reference ) { |
|
107 | + public function findLastReferencePositionEntryFor(DIWikiPage $subject = null, $reference) { |
|
108 | 108 | |
109 | - if ( $subject === null ) { |
|
109 | + if ($subject === null) { |
|
110 | 110 | return; |
111 | 111 | } |
112 | 112 | |
113 | - $referenceHash = md5( $reference ); |
|
113 | + $referenceHash = md5($reference); |
|
114 | 114 | $hash = $subject->getHash(); |
115 | 115 | |
116 | 116 | // Tracks the current parser run invoked by the InTextAnnotationParser |
117 | 117 | $uniqid = $subject->getContextReference(); |
118 | 118 | |
119 | - if ( $this->hasJournalForHash( $hash ) && |
|
119 | + if ($this->hasJournalForHash($hash) && |
|
120 | 120 | self::$citationReferenceJournal[$hash]['uniqid'] === $uniqid && |
121 | - isset( self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash] ) ) { |
|
122 | - return end( self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash] ); |
|
121 | + isset(self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash])) { |
|
122 | + return end(self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash]); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return null; |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | * @param DIWikiPage|null $subject |
132 | 132 | * @param string $reference |
133 | 133 | */ |
134 | - public function addJournalEntryFor( DIWikiPage $subject = null, $reference ) { |
|
134 | + public function addJournalEntryFor(DIWikiPage $subject = null, $reference) { |
|
135 | 135 | |
136 | - if ( $subject === null ) { |
|
136 | + if ($subject === null) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | - $referenceHash = md5( $reference ); |
|
140 | + $referenceHash = md5($reference); |
|
141 | 141 | $hash = $subject->getHash(); |
142 | 142 | |
143 | 143 | // Tracks the current parser run invoked by the InTextAnnotationParser |
144 | 144 | $uniqid = $subject->getContextReference(); |
145 | 145 | |
146 | - if ( !$this->hasJournalForHash( $hash ) || self::$citationReferenceJournal[$hash]['uniqid'] !== $uniqid ) { |
|
146 | + if (!$this->hasJournalForHash($hash) || self::$citationReferenceJournal[$hash]['uniqid'] !== $uniqid) { |
|
147 | 147 | $journal = [ |
148 | 148 | 'uniqid' => $uniqid, |
149 | 149 | 'total' => 0, |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | // New reference, increase the total of existing citations for this |
162 | 162 | // subject and set the position level to 'a' |
163 | - if ( !isset( $journal['reference-pos'][$referenceHash] ) || $journal['reference-pos'][$referenceHash] === [] ) { |
|
163 | + if (!isset($journal['reference-pos'][$referenceHash]) || $journal['reference-pos'][$referenceHash] === []) { |
|
164 | 164 | $journal['total']++; |
165 | 165 | $journal['reference-pos'][$referenceHash][] = $journal['total'] . '-' . 'a'; |
166 | 166 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | // The exact position is specified by something like |
174 | 174 | // like 57d0dc056f9e5d5c6cfc77fc27091f60-1-a and to be used within |
175 | 175 | // html as link anchor |
176 | - list( $major, $minor ) = explode( '-', end( $journal['reference-pos'][$referenceHash] ) ); |
|
176 | + list($major, $minor) = explode('-', end($journal['reference-pos'][$referenceHash])); |
|
177 | 177 | $journal['reference-pos'][$referenceHash][] = $major . '-' . ++$minor; |
178 | 178 | } |
179 | 179 | |
@@ -182,20 +182,20 @@ discard block |
||
182 | 182 | // Safeguard against a repeated call to the hashlist for when the static |
183 | 183 | // cache is empty |
184 | 184 | $this->cache->save( |
185 | - $this->cacheKeyProvider->getCacheKeyForCitationReference( $hash ), |
|
185 | + $this->cacheKeyProvider->getCacheKeyForCitationReference($hash), |
|
186 | 186 | self::$citationReferenceJournal |
187 | 187 | ); |
188 | 188 | } |
189 | 189 | |
190 | - private function hasJournalForHash( $hash ) { |
|
190 | + private function hasJournalForHash($hash) { |
|
191 | 191 | |
192 | - if ( self::$citationReferenceJournal === [] ) { |
|
192 | + if (self::$citationReferenceJournal === []) { |
|
193 | 193 | self::$citationReferenceJournal = $this->cache->fetch( |
194 | - $this->cacheKeyProvider->getCacheKeyForCitationReference( $hash ) |
|
194 | + $this->cacheKeyProvider->getCacheKeyForCitationReference($hash) |
|
195 | 195 | ); |
196 | 196 | } |
197 | 197 | |
198 | - return isset( self::$citationReferenceJournal[$hash] ); |
|
198 | + return isset(self::$citationReferenceJournal[$hash]); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @since 1.0 |
22 | 22 | */ |
23 | - public function __construct( array $options = [] ) { |
|
23 | + public function __construct(array $options = []) { |
|
24 | 24 | $this->options = $options; |
25 | 25 | } |
26 | 26 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string $key |
31 | 31 | * @param mixed $value |
32 | 32 | */ |
33 | - public function set( $key, $value ) { |
|
33 | + public function set($key, $value) { |
|
34 | 34 | $this->options[$key] = $value; |
35 | 35 | } |
36 | 36 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return boolean |
43 | 43 | */ |
44 | - public function has( $key ) { |
|
45 | - return isset( $this->options[$key] ) || array_key_exists( $key, $this->options ); |
|
44 | + public function has($key) { |
|
45 | + return isset($this->options[$key]) || array_key_exists($key, $this->options); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | * @throws InvalidArgumentException |
55 | 55 | */ |
56 | - public function get( $key ) { |
|
56 | + public function get($key) { |
|
57 | 57 | |
58 | - if ( $this->has( $key ) ) { |
|
58 | + if ($this->has($key)) { |
|
59 | 59 | return $this->options[$key]; |
60 | 60 | } |
61 | 61 | |
62 | - throw new InvalidArgumentException( "{$key} is an unregistered option" ); |
|
62 | + throw new InvalidArgumentException("{$key} is an unregistered option"); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param OLFilteredHttpResponseParser $olFilteredHttpResponseParser |
26 | 26 | */ |
27 | - public function __construct( OLFilteredHttpResponseParser $olFilteredHttpResponseParser ) { |
|
27 | + public function __construct(OLFilteredHttpResponseParser $olFilteredHttpResponseParser) { |
|
28 | 28 | $this->olFilteredHttpResponseParser = $olFilteredHttpResponseParser; |
29 | 29 | } |
30 | 30 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * {@inheritDoc} |
62 | 62 | */ |
63 | - public function getRawResponse( $id ) { |
|
64 | - return $this->olFilteredHttpResponseParser->getRawResponse( $id ); |
|
63 | + public function getRawResponse($id) { |
|
64 | + return $this->olFilteredHttpResponseParser->getRawResponse($id); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,39 +69,39 @@ discard block |
||
69 | 69 | * |
70 | 70 | * {@inheritDoc} |
71 | 71 | */ |
72 | - public function doFilterResponseFor( $olID ) { |
|
72 | + public function doFilterResponseFor($olID) { |
|
73 | 73 | |
74 | - $this->olFilteredHttpResponseParser->doFilterResponseFor( $olID ); |
|
74 | + $this->olFilteredHttpResponseParser->doFilterResponseFor($olID); |
|
75 | 75 | $filteredRecord = $this->olFilteredHttpResponseParser->getFilteredRecord(); |
76 | 76 | |
77 | 77 | // Fetch the OLID has one could search for an ISBN as well |
78 | - if ( $filteredRecord->has( 'olid' ) ) { |
|
79 | - $olID = $filteredRecord->get( 'olid' ); |
|
78 | + if ($filteredRecord->has('olid')) { |
|
79 | + $olID = $filteredRecord->get('olid'); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( is_array( $olID ) ) { |
|
83 | - $olID = end( $olID ); |
|
82 | + if (is_array($olID)) { |
|
83 | + $olID = end($olID); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $filteredRecord->setTitleForPageCreation( |
87 | - 'OL:' . str_replace( 'OL', '', $olID ) |
|
87 | + 'OL:' . str_replace('OL', '', $olID) |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | $filteredRecord->setSciteTransclusionHead( |
91 | 91 | $olID |
92 | 92 | ); |
93 | 93 | |
94 | - $filteredRecord->addSearchMatchSet( 'olid', $olID ); |
|
94 | + $filteredRecord->addSearchMatchSet('olid', $olID); |
|
95 | 95 | |
96 | - if ( $filteredRecord->has( 'lccn' ) ) { |
|
96 | + if ($filteredRecord->has('lccn')) { |
|
97 | 97 | $filteredRecord->addSearchMatchSet( |
98 | 98 | 'lccn', |
99 | - $filteredRecord->get( 'lccn' ) |
|
99 | + $filteredRecord->get('lccn') |
|
100 | 100 | ); |
101 | 101 | } |
102 | 102 | |
103 | - $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
104 | - $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
103 | + $dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC')); |
|
104 | + $filteredRecord->set('retrieved-on', $dateTimeUtc->format('Y-m-d')); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param OclcFilteredHttpResponseParser $oclcFilteredHttpResponseParser |
26 | 26 | */ |
27 | - public function __construct( OclcFilteredHttpResponseParser $oclcFilteredHttpResponseParser ) { |
|
27 | + public function __construct(OclcFilteredHttpResponseParser $oclcFilteredHttpResponseParser) { |
|
28 | 28 | $this->oclcFilteredHttpResponseParser = $oclcFilteredHttpResponseParser; |
29 | 29 | } |
30 | 30 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * {@inheritDoc} |
62 | 62 | */ |
63 | - public function getRawResponse( $oclcID ) { |
|
64 | - return $this->oclcFilteredHttpResponseParser->getRawResponse( $oclcID ); |
|
63 | + public function getRawResponse($oclcID) { |
|
64 | + return $this->oclcFilteredHttpResponseParser->getRawResponse($oclcID); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,32 +69,32 @@ discard block |
||
69 | 69 | * |
70 | 70 | * {@inheritDoc} |
71 | 71 | */ |
72 | - public function doFilterResponseFor( $oclcID ) { |
|
72 | + public function doFilterResponseFor($oclcID) { |
|
73 | 73 | |
74 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
75 | 75 | |
76 | - $oclcValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'oclc' ); |
|
77 | - $oclcValue->setUserValue( $oclcID ); |
|
76 | + $oclcValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType('oclc'); |
|
77 | + $oclcValue->setUserValue($oclcID); |
|
78 | 78 | |
79 | - if ( !$oclcValue->isValid() ) { |
|
80 | - return $this->oclcFilteredHttpResponseParser->addMessage( $oclcValue->getErrors() ); |
|
79 | + if (!$oclcValue->isValid()) { |
|
80 | + return $this->oclcFilteredHttpResponseParser->addMessage($oclcValue->getErrors()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $oclcID = $oclcValue->getWikiValue(); |
84 | 84 | |
85 | - $this->oclcFilteredHttpResponseParser->doFilterResponseFor( $oclcID ); |
|
85 | + $this->oclcFilteredHttpResponseParser->doFilterResponseFor($oclcID); |
|
86 | 86 | $filteredRecord = $this->oclcFilteredHttpResponseParser->getFilteredRecord(); |
87 | 87 | |
88 | - $filteredRecord->setTitleForPageCreation( 'OCLC:' . $oclcID ); |
|
88 | + $filteredRecord->setTitleForPageCreation('OCLC:' . $oclcID); |
|
89 | 89 | $filteredRecord->setSciteTransclusionHead( |
90 | 90 | 'OCLC' . $oclcID |
91 | 91 | ); |
92 | 92 | |
93 | - $filteredRecord->addSearchMatchSet( 'oclc', $oclcID ); |
|
94 | - $filteredRecord->set( 'oclc', $oclcID ); |
|
93 | + $filteredRecord->addSearchMatchSet('oclc', $oclcID); |
|
94 | + $filteredRecord->set('oclc', $oclcID); |
|
95 | 95 | |
96 | - $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
97 | - $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
96 | + $dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC')); |
|
97 | + $filteredRecord->set('retrieved-on', $dateTimeUtc->format('Y-m-d')); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param ViafFilteredHttpResponseParser $viafFilteredHttpResponseParser |
26 | 26 | */ |
27 | - public function __construct( ViafFilteredHttpResponseParser $viafFilteredHttpResponseParser ) { |
|
27 | + public function __construct(ViafFilteredHttpResponseParser $viafFilteredHttpResponseParser) { |
|
28 | 28 | $this->viafFilteredHttpResponseParser = $viafFilteredHttpResponseParser; |
29 | 29 | } |
30 | 30 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * {@inheritDoc} |
62 | 62 | */ |
63 | - public function getRawResponse( $viafID ) { |
|
64 | - return $this->viafFilteredHttpResponseParser->getRawResponse( $viafID ); |
|
63 | + public function getRawResponse($viafID) { |
|
64 | + return $this->viafFilteredHttpResponseParser->getRawResponse($viafID); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,31 +69,31 @@ discard block |
||
69 | 69 | * |
70 | 70 | * {@inheritDoc} |
71 | 71 | */ |
72 | - public function doFilterResponseFor( $viafID ) { |
|
72 | + public function doFilterResponseFor($viafID) { |
|
73 | 73 | |
74 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
75 | 75 | |
76 | - $viafValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'viaf' ); |
|
77 | - $viafValue->setUserValue( $viafID ); |
|
76 | + $viafValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType('viaf'); |
|
77 | + $viafValue->setUserValue($viafID); |
|
78 | 78 | |
79 | - if ( !$viafValue->isValid() ) { |
|
80 | - return $this->viafFilteredHttpResponseParser->addMessage( $viafValue->getErrors() ); |
|
79 | + if (!$viafValue->isValid()) { |
|
80 | + return $this->viafFilteredHttpResponseParser->addMessage($viafValue->getErrors()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $viafID = $viafValue->getWikiValue(); |
84 | 84 | |
85 | - $this->viafFilteredHttpResponseParser->doFilterResponseFor( $viafID ); |
|
85 | + $this->viafFilteredHttpResponseParser->doFilterResponseFor($viafID); |
|
86 | 86 | $filteredRecord = $this->viafFilteredHttpResponseParser->getFilteredRecord(); |
87 | 87 | |
88 | - $filteredRecord->setTitleForPageCreation( 'VIAF:' . $viafID ); |
|
88 | + $filteredRecord->setTitleForPageCreation('VIAF:' . $viafID); |
|
89 | 89 | $filteredRecord->setSciteTransclusionHead( |
90 | 90 | 'VIAF' . $viafID |
91 | 91 | ); |
92 | 92 | |
93 | - $filteredRecord->addSearchMatchSet( 'viaf', $viafID ); |
|
93 | + $filteredRecord->addSearchMatchSet('viaf', $viafID); |
|
94 | 94 | |
95 | - $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
96 | - $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
95 | + $dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC')); |
|
96 | + $filteredRecord->set('retrieved-on', $dateTimeUtc->format('Y-m-d')); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |