Completed
Push — master ( 59f8d5...8ba3ac )
by
unknown
09:44
created
src/Api/CheckConstraintsRdf.php 1 patch
Spacing   +26 added lines, -26 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 = null ) {
48
+	public static function newFromGlobalState(Page $page, IContextSource $context = null) {
49 49
 		$repo = WikibaseRepo::getDefaultInstance();
50 50
 		$constraintReportFactory = ConstraintReportFactory::getDefaultInstance();
51 51
 
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @param string $guid
85 85
 	 * @return string
86 86
 	 */
87
-	private function cleanupGuid( $guid ) {
88
-		return preg_replace( '/[^\w-]/', '-', $guid );
87
+	private function cleanupGuid($guid) {
88
+		return preg_replace('/[^\w-]/', '-', $guid);
89 89
 	}
90 90
 
91 91
 	/**
@@ -97,51 +97,51 @@  discard block
 block discarded – undo
97 97
 		$response = $this->getRequest()->response();
98 98
 		$this->getOutput()->disable();
99 99
 
100
-		if ( !$this->resultsSource instanceof CachingResultsSource ) {
100
+		if (!$this->resultsSource instanceof CachingResultsSource) {
101 101
 			// TODO: make configurable whether only cached results are returned
102
-			$response->statusHeader( 501 ); // Not Implemented
102
+			$response->statusHeader(501); // Not Implemented
103 103
 			return null;
104 104
 		}
105 105
 
106
-		$entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() );
107
-		if ( $entityId === null ) {
108
-			$response->statusHeader( 404 ); // Not Found
106
+		$entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle());
107
+		if ($entityId === null) {
108
+			$response->statusHeader(404); // Not Found
109 109
 			return null;
110 110
 		}
111 111
 
112
-		$results = $this->resultsSource->getStoredResults( $entityId );
113
-		if ( $results === null ) {
114
-			$response->statusHeader( 204 ); // No Content
112
+		$results = $this->resultsSource->getStoredResults($entityId);
113
+		if ($results === null) {
114
+			$response->statusHeader(204); // No Content
115 115
 			return null;
116 116
 		}
117 117
 
118 118
 		$format = 'ttl'; // TODO: make format an option
119 119
 
120 120
 		$writerFactory = new RdfWriterFactory();
121
-		$formatName = $writerFactory->getFormatName( $format );
122
-		$contentType = $writerFactory->getMimeTypes( $formatName )[0];
121
+		$formatName = $writerFactory->getFormatName($format);
122
+		$contentType = $writerFactory->getMimeTypes($formatName)[0];
123 123
 
124
-		$response->header( "Content-Type: $contentType; charset=UTF-8" );
124
+		$response->header("Content-Type: $contentType; charset=UTF-8");
125 125
 
126
-		$writer = $writerFactory->getWriter( $formatName );
127
-		foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) {
128
-			$writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) );
126
+		$writer = $writerFactory->getWriter($formatName);
127
+		foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) {
128
+			$writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns));
129 129
 		}
130 130
 		$writer->start();
131 131
 
132
-		foreach ( $results->getArray() as $checkResult ) {
133
-			if ( $checkResult instanceof NullResult ) {
132
+		foreach ($results->getArray() as $checkResult) {
133
+			if ($checkResult instanceof NullResult) {
134 134
 				continue;
135 135
 			}
136
-			if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) {
136
+			if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) {
137 137
 				continue;
138 138
 			}
139 139
 
140
-			$writer->about( RdfVocabulary::NS_STATEMENT,
141
-				$this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) )
142
-				->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' )
143
-				->is( RdfVocabulary::NS_STATEMENT,
144
-					$this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) );
140
+			$writer->about(RdfVocabulary::NS_STATEMENT,
141
+				$this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid()))
142
+				->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint')
143
+				->is(RdfVocabulary::NS_STATEMENT,
144
+					$this->cleanupGuid($checkResult->getConstraint()->getConstraintId()));
145 145
 		}
146 146
 		$writer->finish();
147 147
 		echo $writer->drain();
Please login to merge, or discard this patch.