Completed
Push — master ( 535e17...c4b674 )
by
unknown
22s
created
src/ConstraintParameterRenderer.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string HTML
73 73
 	 */
74
-	public function formatValue( $value ) {
75
-		if ( is_string( $value ) ) {
74
+	public function formatValue($value) {
75
+		if (is_string($value)) {
76 76
 			// Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as
77 77
 			// strings
78
-			return htmlspecialchars( $value );
79
-		} elseif ( $value instanceof EntityId ) {
78
+			return htmlspecialchars($value);
79
+		} elseif ($value instanceof EntityId) {
80 80
 			// Cases like 'Conflicts with' 'property', to which we can link
81
-			return $this->formatEntityId( $value );
82
-		} elseif ( $value instanceof ItemIdSnakValue ) {
81
+			return $this->formatEntityId($value);
82
+		} elseif ($value instanceof ItemIdSnakValue) {
83 83
 			// Cases like EntityId but can also be somevalue or novalue
84
-			return $this->formatItemIdSnakValue( $value );
84
+			return $this->formatItemIdSnakValue($value);
85 85
 		} else {
86 86
 			// Cases where we format a DataValue
87
-			return $this->formatDataValue( $value );
87
+			return $this->formatDataValue($value);
88 88
 		}
89 89
 	}
90 90
 
@@ -95,19 +95,19 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return string|null HTML
97 97
 	 */
98
-	public function formatParameters( $parameters ) {
99
-		if ( $parameters === null || $parameters === [] ) {
98
+	public function formatParameters($parameters) {
99
+		if ($parameters === null || $parameters === []) {
100 100
 			return null;
101 101
 		}
102 102
 
103 103
 		$formattedParameters = [];
104
-		foreach ( $parameters as $parameterName => $parameterValue ) {
105
-			$formattedParameterValues = implode( ', ',
106
-				$this->limitArrayLength( array_map( [ $this, 'formatValue' ], $parameterValue ) ) );
107
-			$formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues );
104
+		foreach ($parameters as $parameterName => $parameterValue) {
105
+			$formattedParameterValues = implode(', ',
106
+				$this->limitArrayLength(array_map([$this, 'formatValue'], $parameterValue)));
107
+			$formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues);
108 108
 		}
109 109
 
110
-		return implode( '; ', $formattedParameters );
110
+		return implode('; ', $formattedParameters);
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return string[]
119 119
 	 */
120
-	private function limitArrayLength( array $array ) {
121
-		if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) {
122
-			$array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH );
123
-			array_push( $array, '...' );
120
+	private function limitArrayLength(array $array) {
121
+		if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) {
122
+			$array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH);
123
+			array_push($array, '...');
124 124
 		}
125 125
 
126 126
 		return $array;
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	 * @param DataValue $value
131 131
 	 * @return string HTML
132 132
 	 */
133
-	public function formatDataValue( DataValue $value ) {
134
-		return $this->dataValueFormatter->format( $value );
133
+	public function formatDataValue(DataValue $value) {
134
+		return $this->dataValueFormatter->format($value);
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * @param EntityId $entityId
139 139
 	 * @return string HTML
140 140
 	 */
141
-	public function formatEntityId( EntityId $entityId ) {
142
-		return $this->entityIdLabelFormatter->formatEntityId( $entityId );
141
+	public function formatEntityId(EntityId $entityId) {
142
+		return $this->entityIdLabelFormatter->formatEntityId($entityId);
143 143
 	}
144 144
 
145 145
 	/**
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
 	 * @param ItemIdSnakValue $value
149 149
 	 * @return string HTML
150 150
 	 */
151
-	public function formatItemIdSnakValue( ItemIdSnakValue $value ) {
152
-		switch ( true ) {
151
+	public function formatItemIdSnakValue(ItemIdSnakValue $value) {
152
+		switch (true) {
153 153
 			case $value->isValue():
154
-				return $this->formatEntityId( $value->getItemId() );
154
+				return $this->formatEntityId($value->getItemId());
155 155
 			case $value->isSomeValue():
156 156
 				return $this->messageLocalizer
157
-					->msg( 'wikibase-snakview-snaktypeselector-somevalue' )
157
+					->msg('wikibase-snakview-snaktypeselector-somevalue')
158 158
 					->escaped();
159 159
 			case $value->isNoValue():
160 160
 				return $this->messageLocalizer
161
-					->msg( 'wikibase-snakview-snaktypeselector-novalue' )
161
+					->msg('wikibase-snakview-snaktypeselector-novalue')
162 162
 					->escaped();
163 163
 		}
164 164
 	}
Please login to merge, or discard this patch.