@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $stringComparer; |
20 | 20 | |
21 | - public function __construct( StringComparer $stringComparer ) { |
|
21 | + public function __construct(StringComparer $stringComparer) { |
|
22 | 22 | $this->stringComparer = $stringComparer; |
23 | 23 | } |
24 | 24 | |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | * @throws InvalidArgumentException |
32 | 32 | * @return string|null One of the ComparisonResult::STATUS_... constants. |
33 | 33 | */ |
34 | - public function compare( DataValue $value, DataValue $comparativeValue ) { |
|
35 | - if ( !$this->canCompare( $value, $comparativeValue ) ) { |
|
36 | - throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' ); |
|
34 | + public function compare(DataValue $value, DataValue $comparativeValue) { |
|
35 | + if (!$this->canCompare($value, $comparativeValue)) { |
|
36 | + throw new InvalidArgumentException('Given values can not be compared using this comparer.'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | |
44 | 44 | $texts = $value->getTexts(); |
45 | 45 | $comparativeTexts = $comparativeValue->getTexts(); |
46 | - $commonLanguages = array_intersect( array_keys( $texts ), array_keys( $comparativeTexts ) ); |
|
46 | + $commonLanguages = array_intersect(array_keys($texts), array_keys($comparativeTexts)); |
|
47 | 47 | |
48 | - if ( $commonLanguages ) { |
|
48 | + if ($commonLanguages) { |
|
49 | 49 | $totalResult = ComparisonResult::STATUS_MISMATCH; |
50 | 50 | |
51 | - foreach ( $commonLanguages as $language ) { |
|
51 | + foreach ($commonLanguages as $language) { |
|
52 | 52 | $monolingualText = $texts[$language]; |
53 | 53 | $comparativeMonolingualText = $comparativeTexts[$language]; |
54 | 54 | |
55 | - $result = $this->stringComparer->compare( $monolingualText->getText(), $comparativeMonolingualText->getText() ); |
|
56 | - if ( $result !== ComparisonResult::STATUS_MISMATCH ) { |
|
55 | + $result = $this->stringComparer->compare($monolingualText->getText(), $comparativeMonolingualText->getText()); |
|
56 | + if ($result !== ComparisonResult::STATUS_MISMATCH) { |
|
57 | 57 | $totalResult = $result; |
58 | 58 | |
59 | 59 | // FIXME: This reports a partial match in a single language as a full match! |
60 | - if ( $result === ComparisonResult::STATUS_MATCH ) { |
|
60 | + if ($result === ComparisonResult::STATUS_MATCH) { |
|
61 | 61 | break; |
62 | 62 | } |
63 | 63 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param DataValue $comparativeValue |
77 | 77 | * @return bool |
78 | 78 | */ |
79 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
79 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
80 | 80 | return $value instanceof MultilingualTextValue && $comparativeValue instanceof MultilingualTextValue; |
81 | 81 | } |
82 | 82 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | private $stringNormalizer; |
23 | 23 | |
24 | - public function __construct( TermIndex $termIndex, StringNormalizer $stringNormalizer ) { |
|
24 | + public function __construct(TermIndex $termIndex, StringNormalizer $stringNormalizer) { |
|
25 | 25 | $this->termIndex = $termIndex; |
26 | 26 | $this->stringNormalizer = $stringNormalizer; |
27 | 27 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return StringComparer |
64 | 64 | */ |
65 | 65 | private function newStringComparer() { |
66 | - return new StringComparer( $this->stringNormalizer ); |
|
66 | + return new StringComparer($this->stringNormalizer); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $stringNormalizer; |
20 | 20 | |
21 | - public function __construct( StringNormalizer $stringNormalizer ) { |
|
21 | + public function __construct(StringNormalizer $stringNormalizer) { |
|
22 | 22 | $this->stringNormalizer = $stringNormalizer; |
23 | 23 | } |
24 | 24 | |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return StringValue |
31 | 31 | */ |
32 | - public function parse( $value ) { |
|
33 | - Assert::parameterType( 'string', $value, '$value' ); |
|
32 | + public function parse($value) { |
|
33 | + Assert::parameterType('string', $value, '$value'); |
|
34 | 34 | |
35 | - return new StringValue( $this->stringNormalizer->trimToNFC( $value ) ); |
|
35 | + return new StringValue($this->stringNormalizer->trimToNFC($value)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | private $monolingualTextValueParser; |
19 | 19 | |
20 | - public function __construct( ValueParser $monolingualTextValueParser ) { |
|
20 | + public function __construct(ValueParser $monolingualTextValueParser) { |
|
21 | 21 | $this->monolingualTextValueParser = $monolingualTextValueParser; |
22 | 22 | } |
23 | 23 | |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return MultilingualTextValue |
30 | 30 | */ |
31 | - public function parse( $value ) { |
|
32 | - Assert::parameterType( 'string', $value, '$value' ); |
|
31 | + public function parse($value) { |
|
32 | + Assert::parameterType('string', $value, '$value'); |
|
33 | 33 | |
34 | 34 | return new MultilingualTextValue( |
35 | - [ $this->monolingualTextValueParser->parse( $value ) ] |
|
35 | + [$this->monolingualTextValueParser->parse($value)] |
|
36 | 36 | ); |
37 | 37 | } |
38 | 38 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $referenceSerializer; |
22 | 22 | |
23 | - public function __construct( Serializer $dataValueSerializer, Serializer $referenceSerializer ) { |
|
23 | + public function __construct(Serializer $dataValueSerializer, Serializer $referenceSerializer) { |
|
24 | 24 | $this->dataValueSerializer = $dataValueSerializer; |
25 | 25 | $this->referenceSerializer = $referenceSerializer; |
26 | 26 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return Serializer |
43 | 43 | */ |
44 | 44 | public function newComparisonResultSerializer() { |
45 | - return new ComparisonResultSerializer( $this->dataValueSerializer ); |
|
45 | + return new ComparisonResultSerializer($this->dataValueSerializer); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return Serializer |
74 | 74 | */ |
75 | 75 | public function newReferenceResultSerializer() { |
76 | - return new ReferenceResultSerializer( $this->referenceSerializer ); |
|
76 | + return new ReferenceResultSerializer($this->referenceSerializer); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $dataValueSerializer; |
20 | 20 | |
21 | - public function __construct( Serializer $dataValueSerializer ) { |
|
21 | + public function __construct(Serializer $dataValueSerializer) { |
|
22 | 22 | $this->dataValueSerializer = $dataValueSerializer; |
23 | 23 | } |
24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | - public function isSerializerFor( $object ) { |
|
32 | + public function isSerializerFor($object) { |
|
33 | 33 | return $object instanceof ComparisonResult; |
34 | 34 | } |
35 | 35 | |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | * @return array |
42 | 42 | * @throws UnsupportedObjectException |
43 | 43 | */ |
44 | - public function serialize( $object ) { |
|
45 | - if ( !$this->isSerializerFor( $object ) ) { |
|
44 | + public function serialize($object) { |
|
45 | + if (!$this->isSerializerFor($object)) { |
|
46 | 46 | throw new UnsupportedObjectException( |
47 | 47 | $object, |
48 | 48 | 'ComparisonResultSerializer can only serialize ComparisonResult objects.' |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - return $this->getSerialized( $object ); |
|
52 | + return $this->getSerialized($object); |
|
53 | 53 | } |
54 | 54 | |
55 | - private function getSerialized( ComparisonResult $comparisonResult ) { |
|
55 | + private function getSerialized(ComparisonResult $comparisonResult) { |
|
56 | 56 | $dataValueSerializer = $this->dataValueSerializer; |
57 | 57 | $externalValues = array_map( |
58 | - function ( $dataValue ) use ( $dataValueSerializer ) { |
|
59 | - return $dataValueSerializer->serialize( $dataValue ); |
|
58 | + function($dataValue) use ($dataValueSerializer) { |
|
59 | + return $dataValueSerializer->serialize($dataValue); |
|
60 | 60 | }, |
61 | 61 | $comparisonResult->getExternalValues() |
62 | 62 | ); |
63 | - $this->setIndexedTagName( $externalValues, 'dataValue' ); |
|
63 | + $this->setIndexedTagName($externalValues, 'dataValue'); |
|
64 | 64 | |
65 | 65 | return [ |
66 | - 'localValue' => $this->dataValueSerializer->serialize( $comparisonResult->getLocalValue() ), |
|
66 | + 'localValue' => $this->dataValueSerializer->serialize($comparisonResult->getLocalValue()), |
|
67 | 67 | 'externalValues' => $externalValues, |
68 | 68 | 'result' => $comparisonResult->getStatus() |
69 | 69 | ]; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $crossCheckResultSerializer; |
20 | 20 | |
21 | - public function __construct( Serializer $crossCheckResultSerializer ) { |
|
21 | + public function __construct(Serializer $crossCheckResultSerializer) { |
|
22 | 22 | $this->crossCheckResultSerializer = $crossCheckResultSerializer; |
23 | 23 | } |
24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | - public function isSerializerFor( $object ) { |
|
32 | + public function isSerializerFor($object) { |
|
33 | 33 | return $object instanceof CrossCheckResultList; |
34 | 34 | } |
35 | 35 | |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | * @return array |
42 | 42 | * @throws UnsupportedObjectException |
43 | 43 | */ |
44 | - public function serialize( $object ) { |
|
45 | - if ( !$this->isSerializerFor( $object ) ) { |
|
44 | + public function serialize($object) { |
|
45 | + if (!$this->isSerializerFor($object)) { |
|
46 | 46 | throw new UnsupportedObjectException( |
47 | 47 | $object, |
48 | 48 | 'CrossCheckResultListSerializer can only serialize CrossCheckResultList objects.' |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - return $this->getSerialized( $object ); |
|
52 | + return $this->getSerialized($object); |
|
53 | 53 | } |
54 | 54 | |
55 | - private function getSerialized( CrossCheckResultList $resultList ) { |
|
55 | + private function getSerialized(CrossCheckResultList $resultList) { |
|
56 | 56 | $serialization = []; |
57 | - $this->setKeyAttributeName( $serialization, 'property', 'id' ); |
|
57 | + $this->setKeyAttributeName($serialization, 'property', 'id'); |
|
58 | 58 | |
59 | - foreach ( $resultList->getPropertyIds() as $propertyId ) { |
|
59 | + foreach ($resultList->getPropertyIds() as $propertyId) { |
|
60 | 60 | $id = $propertyId->getSerialization(); |
61 | 61 | $resultSerialization = []; |
62 | 62 | |
63 | - $this->setIndexedTagName( $resultSerialization, 'result' ); |
|
63 | + $this->setIndexedTagName($resultSerialization, 'result'); |
|
64 | 64 | |
65 | - foreach ( $resultList->getByPropertyId( $propertyId ) as $result ) { |
|
66 | - $resultSerialization[] = $this->crossCheckResultSerializer->serialize( $result ); |
|
65 | + foreach ($resultList->getByPropertyId($propertyId) as $result) { |
|
66 | + $resultSerialization[] = $this->crossCheckResultSerializer->serialize($result); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $serialization[$id] = $resultSerialization; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $referenceSerializer; |
20 | 20 | |
21 | - public function __construct( Serializer $referenceSerializer ) { |
|
21 | + public function __construct(Serializer $referenceSerializer) { |
|
22 | 22 | $this->referenceSerializer = $referenceSerializer; |
23 | 23 | } |
24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | - public function isSerializerFor( $object ) { |
|
32 | + public function isSerializerFor($object) { |
|
33 | 33 | return $object instanceof ReferenceResult; |
34 | 34 | } |
35 | 35 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | * @return array |
42 | 42 | * @throws UnsupportedObjectException |
43 | 43 | */ |
44 | - public function serialize( $object ) { |
|
45 | - if ( !$this->isSerializerFor( $object ) ) { |
|
44 | + public function serialize($object) { |
|
45 | + if (!$this->isSerializerFor($object)) { |
|
46 | 46 | throw new UnsupportedObjectException( |
47 | 47 | $object, |
48 | 48 | 'ReferenceResultSerializer can only serialize ReferenceResult objects.' |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - return $this->getSerialized( $object ); |
|
52 | + return $this->getSerialized($object); |
|
53 | 53 | } |
54 | 54 | |
55 | - private function getSerialized( ReferenceResult $referenceResult ) { |
|
55 | + private function getSerialized(ReferenceResult $referenceResult) { |
|
56 | 56 | return [ |
57 | - 'reference' => $this->referenceSerializer->serialize( $referenceResult->getReference() ), |
|
57 | + 'reference' => $this->referenceSerializer->serialize($referenceResult->getReference()), |
|
58 | 58 | 'status' => $referenceResult->getStatus() |
59 | 59 | ]; |
60 | 60 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | EntityIdHtmlLinkFormatterFactory $entityIdHtmlLinkFormatterFactory, |
54 | 54 | DumpMetaInformationLookup $dumpMetaInformationRepo |
55 | 55 | ) { |
56 | - parent::__construct( 'ExternalDatabases' ); |
|
56 | + parent::__construct('ExternalDatabases'); |
|
57 | 57 | |
58 | 58 | $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( |
59 | - new LanguageLabelDescriptionLookup( $termLookup, $this->getLanguage()->getCode() ) |
|
59 | + new LanguageLabelDescriptionLookup($termLookup, $this->getLanguage()->getCode()) |
|
60 | 60 | ); |
61 | 61 | |
62 | 62 | $this->dumpMetaInformationRepo = $dumpMetaInformationRepo; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return string |
78 | 78 | */ |
79 | 79 | public function getDescription() { |
80 | - return $this->msg( 'wbqev-externaldbs' )->text(); |
|
80 | + return $this->msg('wbqev-externaldbs')->text(); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -85,51 +85,51 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param string|null $subPage |
87 | 87 | */ |
88 | - public function execute( $subPage ) { |
|
88 | + public function execute($subPage) { |
|
89 | 89 | $out = $this->getOutput(); |
90 | 90 | |
91 | 91 | $this->setHeaders(); |
92 | 92 | |
93 | 93 | $out->addHTML( |
94 | - Html::openElement( 'p' ) |
|
95 | - . $this->msg( 'wbqev-externaldbs-instructions' )->parse() |
|
96 | - . Html::closeElement( 'p' ) |
|
97 | - . Html::openElement( 'h3' ) |
|
98 | - . $this->msg( 'wbqev-externaldbs-overview-headline' )->parse() |
|
99 | - . Html::closeElement( 'h3' ) |
|
94 | + Html::openElement('p') |
|
95 | + . $this->msg('wbqev-externaldbs-instructions')->parse() |
|
96 | + . Html::closeElement('p') |
|
97 | + . Html::openElement('h3') |
|
98 | + . $this->msg('wbqev-externaldbs-overview-headline')->parse() |
|
99 | + . Html::closeElement('h3') |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | $dumps = $this->dumpMetaInformationRepo->getAll(); |
103 | - if ( count( $dumps ) > 0 ) { |
|
103 | + if (count($dumps) > 0) { |
|
104 | 104 | $groupedDumpMetaInformation = []; |
105 | - foreach ( $dumps as $dump ) { |
|
105 | + foreach ($dumps as $dump) { |
|
106 | 106 | $sourceItemId = $dump->getSourceItemId()->getSerialization(); |
107 | 107 | $groupedDumpMetaInformation[$sourceItemId][] = $dump; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $table = new HtmlTableBuilder( |
111 | 111 | [ |
112 | - $this->msg( 'wbqev-externaldbs-name' )->escaped(), |
|
113 | - $this->msg( 'wbqev-externaldbs-id' )->escaped(), |
|
114 | - $this->msg( 'wbqev-externaldbs-import-date' )->escaped(), |
|
115 | - $this->msg( 'wbqev-externaldbs-language' )->escaped(), |
|
116 | - $this->msg( 'wbqev-externaldbs-source-urls' )->escaped(), |
|
117 | - $this->msg( 'wbqev-externaldbs-size' )->escaped(), |
|
118 | - $this->msg( 'wbqev-externaldbs-license' )->escaped() |
|
112 | + $this->msg('wbqev-externaldbs-name')->escaped(), |
|
113 | + $this->msg('wbqev-externaldbs-id')->escaped(), |
|
114 | + $this->msg('wbqev-externaldbs-import-date')->escaped(), |
|
115 | + $this->msg('wbqev-externaldbs-language')->escaped(), |
|
116 | + $this->msg('wbqev-externaldbs-source-urls')->escaped(), |
|
117 | + $this->msg('wbqev-externaldbs-size')->escaped(), |
|
118 | + $this->msg('wbqev-externaldbs-license')->escaped() |
|
119 | 119 | ], |
120 | 120 | true |
121 | 121 | ); |
122 | 122 | |
123 | - foreach ( $groupedDumpMetaInformation as $dumpMetaInformation ) { |
|
124 | - $table->appendRows( $this->getRowGroup( $dumpMetaInformation ) ); |
|
123 | + foreach ($groupedDumpMetaInformation as $dumpMetaInformation) { |
|
124 | + $table->appendRows($this->getRowGroup($dumpMetaInformation)); |
|
125 | 125 | } |
126 | 126 | |
127 | - $out->addHTML( $table->toHtml() ); |
|
127 | + $out->addHTML($table->toHtml()); |
|
128 | 128 | } else { |
129 | 129 | $out->addHTML( |
130 | - Html::openElement( 'p' ) |
|
131 | - . $this->msg( 'wbqev-externaldbs-no-databases' )->escaped() |
|
132 | - . Html::closeElement( 'p' ) |
|
130 | + Html::openElement('p') |
|
131 | + . $this->msg('wbqev-externaldbs-no-databases')->escaped() |
|
132 | + . Html::closeElement('p') |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | } |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return array |
143 | 143 | */ |
144 | - private function getRowGroup( array $dumpMetaInformationGroup ) { |
|
144 | + private function getRowGroup(array $dumpMetaInformationGroup) { |
|
145 | 145 | $rows = []; |
146 | 146 | |
147 | - foreach ( $dumpMetaInformationGroup as $dumpMetaInformation ) { |
|
147 | + foreach ($dumpMetaInformationGroup as $dumpMetaInformation) { |
|
148 | 148 | $dumpId = $dumpMetaInformation->getDumpId(); |
149 | - $importDate = $this->getLanguage()->timeanddate( $dumpMetaInformation->getImportDate() ); |
|
149 | + $importDate = $this->getLanguage()->timeanddate($dumpMetaInformation->getImportDate()); |
|
150 | 150 | $language = Language::fetchLanguageName( |
151 | 151 | $dumpMetaInformation->getLanguageCode(), |
152 | 152 | $this->getLanguage()->getCode() |
@@ -155,23 +155,23 @@ discard block |
||
155 | 155 | $dumpMetaInformation->getSourceUrl(), |
156 | 156 | $dumpMetaInformation->getSourceUrl() |
157 | 157 | ); |
158 | - $size = $this->getLanguage()->formatSize( $dumpMetaInformation->getSize() ); |
|
159 | - $license = $this->entityIdLinkFormatter->formatEntityId( $dumpMetaInformation->getLicenseItemId() ); |
|
158 | + $size = $this->getLanguage()->formatSize($dumpMetaInformation->getSize()); |
|
159 | + $license = $this->entityIdLinkFormatter->formatEntityId($dumpMetaInformation->getLicenseItemId()); |
|
160 | 160 | $rows[] = [ |
161 | - new HtmlTableCellBuilder( $dumpId ), |
|
162 | - new HtmlTableCellBuilder( $importDate ), |
|
163 | - new HtmlTableCellBuilder( $language ), |
|
164 | - new HtmlTableCellBuilder( $sourceUrl, [], true ), |
|
165 | - new HtmlTableCellBuilder( $size ), |
|
166 | - new HtmlTableCellBuilder( $license, [], true ) |
|
161 | + new HtmlTableCellBuilder($dumpId), |
|
162 | + new HtmlTableCellBuilder($importDate), |
|
163 | + new HtmlTableCellBuilder($language), |
|
164 | + new HtmlTableCellBuilder($sourceUrl, [], true), |
|
165 | + new HtmlTableCellBuilder($size), |
|
166 | + new HtmlTableCellBuilder($license, [], true) |
|
167 | 167 | ]; |
168 | 168 | } |
169 | 169 | |
170 | 170 | array_unshift( |
171 | 171 | $rows[0], |
172 | 172 | new HtmlTableCellBuilder( |
173 | - $this->entityIdLinkFormatter->formatEntityId( $dumpMetaInformationGroup[0]->getSourceItemId() ), |
|
174 | - [ 'rowspan' => (string)count( $dumpMetaInformationGroup ) ], |
|
173 | + $this->entityIdLinkFormatter->formatEntityId($dumpMetaInformationGroup[0]->getSourceItemId()), |
|
174 | + ['rowspan' => (string)count($dumpMetaInformationGroup)], |
|
175 | 175 | true |
176 | 176 | ) |
177 | 177 | ); |