Completed
Push — master ( a79e13...e387b8 )
by
unknown
36s queued 15s
created
src/ConstraintCheck/Cache/DependencyMetadata.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param EntityId $entityId An entity ID from which the value was derived.
38 38
 	 * @return self Indication that a value was derived from the entity with the given ID.
39 39
 	 */
40
-	public static function ofEntityId( EntityId $entityId ) {
40
+	public static function ofEntityId(EntityId $entityId) {
41 41
 		$ret = new self;
42 42
 		$ret->entityIds[] = $entityId;
43 43
 		return $ret;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return self Indication that a value will only remain valid
50 50
 	 * as long as the given time value is in the future, not in the past.
51 51
 	 */
52
-	public static function ofFutureTime( TimeValue $timeValue ) {
52
+	public static function ofFutureTime(TimeValue $timeValue) {
53 53
 		$ret = new self;
54 54
 		$ret->timeValue = $timeValue;
55 55
 		return $ret;
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 	 * @param self[] $metadatas
60 60
 	 * @return self
61 61
 	 */
62
-	public static function merge( array $metadatas ) {
63
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
62
+	public static function merge(array $metadatas) {
63
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
64 64
 		$ret = new self;
65 65
 		$entityIds = [];
66
-		foreach ( $metadatas as $metadata ) {
67
-			foreach ( $metadata->entityIds as $entityId ) {
66
+		foreach ($metadatas as $metadata) {
67
+			foreach ($metadata->entityIds as $entityId) {
68 68
 				$entityIds[$entityId->getSerialization()] = $entityId;
69 69
 			}
70
-			$ret->timeValue = self::minTimeValue( $ret->timeValue, $metadata->timeValue );
70
+			$ret->timeValue = self::minTimeValue($ret->timeValue, $metadata->timeValue);
71 71
 		}
72
-		$ret->entityIds = array_values( $entityIds );
72
+		$ret->entityIds = array_values($entityIds);
73 73
 		return $ret;
74 74
 	}
75 75
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	 * @param TimeValue|null $t2
79 79
 	 * @return TimeValue|null
80 80
 	 */
81
-	private static function minTimeValue( ?TimeValue $t1, ?TimeValue $t2 ) {
82
-		if ( $t1 === null ) {
81
+	private static function minTimeValue(?TimeValue $t1, ?TimeValue $t2) {
82
+		if ($t1 === null) {
83 83
 			return $t2;
84 84
 		}
85
-		if ( $t2 === null ) {
85
+		if ($t2 === null) {
86 86
 			return $t1;
87 87
 		}
88
-		return ( new TimeValueComparer() )->getMinimum( $t1, $t2 );
88
+		return (new TimeValueComparer())->getMinimum($t1, $t2);
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/RangeCheckerHelper.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$this->config = $config;
54 54
 		$this->timeParser = new IsoTimestampParser();
55 55
 		$this->timeCalculator = new TimeValueCalculator();
56
-		$this->timeValueComparer = new TimeValueComparer( $this->timeCalculator );
56
+		$this->timeValueComparer = new TimeValueComparer($this->timeCalculator);
57 57
 		$this->unitConverter = $unitConverter;
58 58
 	}
59 59
 
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 	 * @param UnboundedQuantityValue $value
62 62
 	 * @return UnboundedQuantityValue $value converted to standard units if possible, otherwise unchanged $value.
63 63
 	 */
64
-	private function standardize( UnboundedQuantityValue $value ) {
65
-		if ( $this->unitConverter !== null ) {
66
-			$standard = $this->unitConverter->toStandardUnits( $value );
67
-			if ( $standard !== null ) {
64
+	private function standardize(UnboundedQuantityValue $value) {
65
+		if ($this->unitConverter !== null) {
66
+			$standard = $this->unitConverter->toStandardUnits($value);
67
+			if ($standard !== null) {
68 68
 				return $standard;
69 69
 			} else {
70 70
 				return $value;
@@ -86,33 +86,33 @@  discard block
 block discarded – undo
86 86
 	 *                 when $lhs is respectively less than, equal to, or greater than $rhs.
87 87
 	 *                 (In other words, just like the “spaceship” operator <=>.)
88 88
 	 */
89
-	public function getComparison( ?DataValue $lhs, ?DataValue $rhs ) {
90
-		if ( $lhs === null || $rhs === null ) {
89
+	public function getComparison(?DataValue $lhs, ?DataValue $rhs) {
90
+		if ($lhs === null || $rhs === null) {
91 91
 			return 0;
92 92
 		}
93 93
 
94
-		if ( $lhs->getType() !== $rhs->getType() ) {
95
-			throw new InvalidArgumentException( 'Different data value types' );
94
+		if ($lhs->getType() !== $rhs->getType()) {
95
+			throw new InvalidArgumentException('Different data value types');
96 96
 		}
97 97
 
98
-		switch ( $lhs->getType() ) {
98
+		switch ($lhs->getType()) {
99 99
 			case 'time':
100 100
 				/** @var TimeValue $lhs */
101 101
 				/** @var TimeValue $rhs */
102 102
 				'@phan-var TimeValue $lhs';
103 103
 				'@phan-var TimeValue $rhs';
104
-				return $this->timeValueComparer->getComparison( $lhs, $rhs );
104
+				return $this->timeValueComparer->getComparison($lhs, $rhs);
105 105
 			case 'quantity':
106 106
 				/** @var QuantityValue|UnboundedQuantityValue $lhs */
107 107
 				/** @var QuantityValue|UnboundedQuantityValue $rhs */
108 108
 				'@phan-var QuantityValue|UnboundedQuantityValue $lhs';
109 109
 				'@phan-var QuantityValue|UnboundedQuantityValue $rhs';
110
-				$lhsStandard = $this->standardize( $lhs );
111
-				$rhsStandard = $this->standardize( $rhs );
112
-				return $lhsStandard->getAmount()->compare( $rhsStandard->getAmount() );
110
+				$lhsStandard = $this->standardize($lhs);
111
+				$rhsStandard = $this->standardize($rhs);
112
+				return $lhsStandard->getAmount()->compare($rhsStandard->getAmount());
113 113
 		}
114 114
 
115
-		throw new InvalidArgumentException( 'Unsupported data value type' );
115
+		throw new InvalidArgumentException('Unsupported data value type');
116 116
 	}
117 117
 
118 118
 	/**
@@ -127,71 +127,71 @@  discard block
 block discarded – undo
127 127
 	 * @throws InvalidArgumentException if the values do not both have the same, supported data value type
128 128
 	 * @return UnboundedQuantityValue
129 129
 	 */
130
-	public function getDifference( DataValue $minuend, DataValue $subtrahend ) {
131
-		if ( $minuend->getType() === 'time' && $subtrahend->getType() === 'time' ) {
132
-			$minuendSeconds = $this->timeCalculator->getTimestamp( $minuend );
133
-			$subtrahendSeconds = $this->timeCalculator->getTimestamp( $subtrahend );
130
+	public function getDifference(DataValue $minuend, DataValue $subtrahend) {
131
+		if ($minuend->getType() === 'time' && $subtrahend->getType() === 'time') {
132
+			$minuendSeconds = $this->timeCalculator->getTimestamp($minuend);
133
+			$subtrahendSeconds = $this->timeCalculator->getTimestamp($subtrahend);
134 134
 			return UnboundedQuantityValue::newFromNumber(
135 135
 				$minuendSeconds - $subtrahendSeconds,
136
-				$this->config->get( 'WBQualityConstraintsSecondUnit' )
136
+				$this->config->get('WBQualityConstraintsSecondUnit')
137 137
 			);
138 138
 		}
139
-		if ( $minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity' ) {
140
-			$minuendStandard = $this->standardize( $minuend );
141
-			$subtrahendStandard = $this->standardize( $subtrahend );
139
+		if ($minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity') {
140
+			$minuendStandard = $this->standardize($minuend);
141
+			$subtrahendStandard = $this->standardize($subtrahend);
142 142
 			$minuendValue = $minuendStandard->getAmount()->getValueFloat();
143 143
 			$subtrahendValue = $subtrahendStandard->getAmount()->getValueFloat();
144 144
 			$diff = $minuendValue - $subtrahendValue;
145 145
 			// we don’t check whether both quantities have the same standard unit –
146 146
 			// that’s the job of a different constraint type, Units (T164372)
147
-			return UnboundedQuantityValue::newFromNumber( $diff, $minuendStandard->getUnit() );
147
+			return UnboundedQuantityValue::newFromNumber($diff, $minuendStandard->getUnit());
148 148
 		}
149 149
 
150
-		throw new InvalidArgumentException( 'Unsupported or different data value types' );
150
+		throw new InvalidArgumentException('Unsupported or different data value types');
151 151
 	}
152 152
 
153
-	public function getDifferenceInYears( TimeValue $minuend, TimeValue $subtrahend ) {
154
-		if ( !preg_match( '/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches ) ||
155
-			!preg_match( '/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches )
153
+	public function getDifferenceInYears(TimeValue $minuend, TimeValue $subtrahend) {
154
+		if (!preg_match('/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches) ||
155
+			!preg_match('/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches)
156 156
 		) {
157
-			throw new InvalidArgumentException( 'TimeValue::getTime() did not match expected format' );
157
+			throw new InvalidArgumentException('TimeValue::getTime() did not match expected format');
158 158
 		}
159
-		$minuendYear = (float)$minuendMatches[1];
160
-		$subtrahendYear = (float)$subtrahendMatches[1];
159
+		$minuendYear = (float) $minuendMatches[1];
160
+		$subtrahendYear = (float) $subtrahendMatches[1];
161 161
 		$minuendRest = $minuendMatches[2];
162 162
 		$subtrahendRest = $subtrahendMatches[2];
163 163
 
164 164
 		// calculate difference of years
165 165
 		$diff = $minuendYear - $subtrahendYear;
166
-		if ( $minuendYear > 0.0 && $subtrahendYear < 0.0 ) {
166
+		if ($minuendYear > 0.0 && $subtrahendYear < 0.0) {
167 167
 			$diff -= 1.0; // there is no year 0, remove it from difference
168
-		} elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0 ) {
168
+		} elseif ($minuendYear < 0.0 && $subtrahendYear > 0.0) {
169 169
 			$diff -= -1.0; // there is no year 0, remove it from negative difference
170 170
 		}
171 171
 
172 172
 		// adjust for date within year by parsing the month-day part within the same year
173
-		$minuendDateValue = $this->timeParser->parse( '+0000000000001970-' . $minuendRest );
174
-		$subtrahendDateValue = $this->timeParser->parse( '+0000000000001970-' . $subtrahendRest );
175
-		$minuendDateSeconds = $this->timeCalculator->getTimestamp( $minuendDateValue );
176
-		$subtrahendDateSeconds = $this->timeCalculator->getTimestamp( $subtrahendDateValue );
177
-		if ( $minuendDateSeconds < $subtrahendDateSeconds ) {
173
+		$minuendDateValue = $this->timeParser->parse('+0000000000001970-'.$minuendRest);
174
+		$subtrahendDateValue = $this->timeParser->parse('+0000000000001970-'.$subtrahendRest);
175
+		$minuendDateSeconds = $this->timeCalculator->getTimestamp($minuendDateValue);
176
+		$subtrahendDateSeconds = $this->timeCalculator->getTimestamp($subtrahendDateValue);
177
+		if ($minuendDateSeconds < $subtrahendDateSeconds) {
178 178
 			// difference in the last year is actually less than one full year
179 179
 			// e. g. 1975-03-01 - 1974-09-01 is just six months
180 180
 			// (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough)
181 181
 			$diff -= 0.5;
182
-		} elseif ( $minuendDateSeconds > $subtrahendDateSeconds ) {
182
+		} elseif ($minuendDateSeconds > $subtrahendDateSeconds) {
183 183
 			// difference in the last year is actually more than one full year
184 184
 			// e. g. 1975-09-01 - 1974-03-01 is 18 months
185 185
 			// (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough)
186 186
 			$diff += 0.5;
187 187
 		}
188 188
 
189
-		$unit = $this->config->get( 'WBQualityConstraintsYearUnit' );
190
-		return UnboundedQuantityValue::newFromNumber( $diff, $unit );
189
+		$unit = $this->config->get('WBQualityConstraintsYearUnit');
190
+		return UnboundedQuantityValue::newFromNumber($diff, $unit);
191 191
 	}
192 192
 
193
-	public function isFutureTime( TimeValue $timeValue ) {
194
-		return $this->timeValueComparer->isFutureTime( $timeValue );
193
+	public function isFutureTime(TimeValue $timeValue) {
194
+		return $this->timeValueComparer->isFutureTime($timeValue);
195 195
 	}
196 196
 
197 197
 }
Please login to merge, or discard this patch.