Completed
Push — master ( 94aa8a...2ae031 )
by
unknown
09:42 queued 11s
created
src/Api/CheckConstraintsRdf.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		EntityIdLookup $entityIdLookup,
40 40
 		RdfVocabulary $rdfVocabulary
41 41
 	) {
42
-		parent::__construct( $page, $context );
42
+		parent::__construct($page, $context);
43 43
 		$this->resultsSource = $resultsSource;
44 44
 		$this->entityIdLookup = $entityIdLookup;
45 45
 		$this->rdfVocabulary = $rdfVocabulary;
46 46
 	}
47 47
 
48
-	public static function newFromGlobalState( Page $page, IContextSource $context ) {
48
+	public static function newFromGlobalState(Page $page, IContextSource $context) {
49 49
 		$repo = WikibaseRepo::getDefaultInstance();
50 50
 
51 51
 		return new static(
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 * @param string $guid
93 93
 	 * @return string
94 94
 	 */
95
-	private function cleanupGuid( $guid ) {
96
-		return preg_replace( '/[^\w-]/', '-', $guid );
95
+	private function cleanupGuid($guid) {
96
+		return preg_replace('/[^\w-]/', '-', $guid);
97 97
 	}
98 98
 
99 99
 	/**
@@ -105,59 +105,59 @@  discard block
 block discarded – undo
105 105
 		$response = $this->getRequest()->response();
106 106
 		$this->getOutput()->disable();
107 107
 
108
-		if ( !$this->resultsSource instanceof CachingResultsSource ) {
108
+		if (!$this->resultsSource instanceof CachingResultsSource) {
109 109
 			// TODO: make configurable whether only cached results are returned
110
-			$response->statusHeader( 501 ); // Not Implemented
110
+			$response->statusHeader(501); // Not Implemented
111 111
 			return null;
112 112
 		}
113 113
 
114
-		$entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() );
115
-		if ( $entityId === null ) {
116
-			$response->statusHeader( 404 ); // Not Found
114
+		$entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle());
115
+		if ($entityId === null) {
116
+			$response->statusHeader(404); // Not Found
117 117
 			return null;
118 118
 		}
119 119
 
120
-		$results = $this->resultsSource->getStoredResults( $entityId );
121
-		if ( $results === null ) {
122
-			$response->statusHeader( 204 ); // No Content
120
+		$results = $this->resultsSource->getStoredResults($entityId);
121
+		if ($results === null) {
122
+			$response->statusHeader(204); // No Content
123 123
 			return null;
124 124
 		}
125 125
 
126 126
 		$format = 'ttl'; // TODO: make format an option
127 127
 
128 128
 		$writerFactory = new RdfWriterFactory();
129
-		$formatName = $writerFactory->getFormatName( $format );
130
-		$contentType = $writerFactory->getMimeTypes( $formatName )[0];
129
+		$formatName = $writerFactory->getFormatName($format);
130
+		$contentType = $writerFactory->getMimeTypes($formatName)[0];
131 131
 
132
-		$writer = $writerFactory->getWriter( $formatName );
133
-		foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) {
134
-			$writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) );
132
+		$writer = $writerFactory->getWriter($formatName);
133
+		foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) {
134
+			$writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns));
135 135
 		}
136 136
 		$writer->start();
137 137
 		$writtenAny = false;
138 138
 
139
-		foreach ( $results->getArray() as $checkResult ) {
140
-			if ( $checkResult instanceof NullResult ) {
139
+		foreach ($results->getArray() as $checkResult) {
140
+			if ($checkResult instanceof NullResult) {
141 141
 				continue;
142 142
 			}
143
-			if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) {
143
+			if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) {
144 144
 				continue;
145 145
 			}
146 146
 			$writtenAny = true;
147
-			$writer->about( RdfVocabulary::NS_STATEMENT,
148
-				$this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) )
149
-				->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' )
150
-				->is( RdfVocabulary::NS_STATEMENT,
151
-					$this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) );
147
+			$writer->about(RdfVocabulary::NS_STATEMENT,
148
+				$this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid()))
149
+				->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint')
150
+				->is(RdfVocabulary::NS_STATEMENT,
151
+					$this->cleanupGuid($checkResult->getConstraint()->getConstraintId()));
152 152
 		}
153 153
 		$writer->finish();
154
-		if ( $writtenAny ) {
155
-			$response->header( "Content-Type: $contentType; charset=UTF-8" );
154
+		if ($writtenAny) {
155
+			$response->header("Content-Type: $contentType; charset=UTF-8");
156 156
 			echo $writer->drain();
157 157
 		} else {
158 158
 			// Do not output RDF if we haven't written any actual statements. Output 204 instead
159 159
 			$writer->drain();
160
-			$response->statusHeader( 204 ); // No Content
160
+			$response->statusHeader(204); // No Content
161 161
 		}
162 162
 		return null;
163 163
 	}
Please login to merge, or discard this patch.