| @@ -1,16 +1,16 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types = 1); | |
| 4 | 4 | |
| 5 | -if ( PHP_SAPI !== 'cli' ) { | |
| 6 | - die( 'Not an entry point' ); | |
| 5 | +if (PHP_SAPI !== 'cli') { | |
| 6 | +	die('Not an entry point'); | |
| 7 | 7 | } | 
| 8 | 8 | |
| 9 | 9 | error_reporting( -1 ); | 
| 10 | -ini_set( 'display_errors', '1' ); | |
| 10 | +ini_set('display_errors', '1'); | |
| 11 | 11 | |
| 12 | -if ( !is_readable( __DIR__ . '/../vendor/autoload.php' ) ) { | |
| 13 | - die( 'You need to install this package with Composer before you can run the tests' ); | |
| 12 | +if (!is_readable(__DIR__.'/../vendor/autoload.php')) { | |
| 13 | +	die('You need to install this package with Composer before you can run the tests'); | |
| 14 | 14 | } | 
| 15 | 15 | |
| 16 | -require __DIR__ . '/../vendor/autoload.php'; | |
| 16 | +require __DIR__.'/../vendor/autoload.php'; | |
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types = 1); | |
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Euro; | 
| 6 | 6 | |
| @@ -21,9 +21,9 @@ discard block | ||
| 21 | 21 | * @param int $cents | 
| 22 | 22 | * @throws InvalidArgumentException | 
| 23 | 23 | */ | 
| 24 | -	private function __construct( int $cents ) { | |
| 25 | -		if ( $cents < 0 ) { | |
| 26 | - throw new InvalidArgumentException( 'Amount needs to be positive' ); | |
| 24 | +	private function __construct(int $cents) { | |
| 25 | +		if ($cents < 0) { | |
| 26 | +			throw new InvalidArgumentException('Amount needs to be positive'); | |
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 | $this->cents = $cents; | 
| @@ -34,8 +34,8 @@ discard block | ||
| 34 | 34 | * @return self | 
| 35 | 35 | * @throws InvalidArgumentException | 
| 36 | 36 | */ | 
| 37 | -	public static function newFromCents( int $cents ): self { | |
| 38 | - return new self( $cents ); | |
| 37 | +	public static function newFromCents(int $cents): self { | |
| 38 | + return new self($cents); | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | /** | 
| @@ -49,12 +49,12 @@ discard block | ||
| 49 | 49 | * @return self | 
| 50 | 50 | * @throws InvalidArgumentException | 
| 51 | 51 | */ | 
| 52 | -	public static function newFromString( string $euroAmount ): self { | |
| 53 | -		if ( !is_numeric( $euroAmount ) ) { | |
| 54 | - throw new InvalidArgumentException( 'Not a number' ); | |
| 52 | +	public static function newFromString(string $euroAmount): self { | |
| 53 | +		if (!is_numeric($euroAmount)) { | |
| 54 | +			throw new InvalidArgumentException('Not a number'); | |
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | - return self::newFromFloat( (float) $euroAmount ); | |
| 57 | + return self::newFromFloat((float) $euroAmount); | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | /** | 
| @@ -66,13 +66,13 @@ discard block | ||
| 66 | 66 | * @return self | 
| 67 | 67 | * @throws InvalidArgumentException | 
| 68 | 68 | */ | 
| 69 | -	public static function newFromFloat( float $euroAmount ) { | |
| 70 | - return new self( intval( | |
| 69 | +	public static function newFromFloat(float $euroAmount) { | |
| 70 | + return new self(intval( | |
| 71 | 71 | round( | 
| 72 | - round( $euroAmount, self::$DECIMAL_COUNT ) * self::$CENTS_PER_EURO, | |
| 72 | + round($euroAmount, self::$DECIMAL_COUNT) * self::$CENTS_PER_EURO, | |
| 73 | 73 | 0 | 
| 74 | 74 | ) | 
| 75 | - ) ); | |
| 75 | + )); | |
| 76 | 76 | } | 
| 77 | 77 | |
| 78 | 78 | /** | 
| @@ -80,8 +80,8 @@ discard block | ||
| 80 | 80 | * @return self | 
| 81 | 81 | * @throws InvalidArgumentException | 
| 82 | 82 | */ | 
| 83 | -	public static function newFromInt( int $euroAmount ) { | |
| 84 | - return new self( $euroAmount * self::$CENTS_PER_EURO ); | |
| 83 | +	public static function newFromInt(int $euroAmount) { | |
| 84 | + return new self($euroAmount * self::$CENTS_PER_EURO); | |
| 85 | 85 | } | 
| 86 | 86 | |
| 87 | 87 |  	public function getEuroCents(): int { | 
| @@ -96,10 +96,10 @@ discard block | ||
| 96 | 96 | * Returns the euro amount as string with two decimals always present in format "42.00". | 
| 97 | 97 | */ | 
| 98 | 98 |  	public function getEuroString(): string { | 
| 99 | - return number_format( $this->getEuroFloat(), self::$DECIMAL_COUNT, '.', '' ); | |
| 99 | + return number_format($this->getEuroFloat(), self::$DECIMAL_COUNT, '.', ''); | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | -	public function equals( Euro $euro ): bool { | |
| 102 | +	public function equals(Euro $euro): bool { | |
| 103 | 103 | return $this->cents === $euro->cents; | 
| 104 | 104 | } | 
| 105 | 105 | |
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types = 1); | |
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Euro\Tests\Unit; | 
| 6 | 6 | |
| @@ -18,190 +18,190 @@ discard block | ||
| 18 | 18 | /** | 
| 19 | 19 | * @dataProvider unsignedIntegerProvider | 
| 20 | 20 | */ | 
| 21 | -	public function testGetCentsReturnsConstructorArgument( int $unsignedInteger ) { | |
| 22 | - $amount = Euro::newFromCents( $unsignedInteger ); | |
| 23 | - $this->assertSame( $unsignedInteger, $amount->getEuroCents() ); | |
| 21 | +	public function testGetCentsReturnsConstructorArgument(int $unsignedInteger) { | |
| 22 | + $amount = Euro::newFromCents($unsignedInteger); | |
| 23 | + $this->assertSame($unsignedInteger, $amount->getEuroCents()); | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 |  	public function unsignedIntegerProvider() { | 
| 27 | 27 | return [ | 
| 28 | - [ 0 ], [ 1 ], [ 2 ], [ 9 ], [ 10 ], [ 11 ], | |
| 29 | - [ 99 ], [ 100 ], [ 101 ], [ 999 ], [ 1000 ], [ 1001 ], | |
| 28 | + [0], [1], [2], [9], [10], [11], | |
| 29 | + [99], [100], [101], [999], [1000], [1001], | |
| 30 | 30 | ]; | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 |  	public function testGivenZero_getEuroFloatReturnsZeroFloat() { | 
| 34 | - $amount = Euro::newFromCents( 0 ); | |
| 35 | - $this->assertExactFloat( 0.0, $amount->getEuroFloat() ); | |
| 36 | - $this->assertNotSame( 0, $amount->getEuroFloat() ); | |
| 34 | + $amount = Euro::newFromCents(0); | |
| 35 | + $this->assertExactFloat(0.0, $amount->getEuroFloat()); | |
| 36 | + $this->assertNotSame(0, $amount->getEuroFloat()); | |
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | -	private function assertExactFloat( float $expected, $actual ) { | |
| 40 | - $this->assertInternalType( 'float', $actual ); | |
| 41 | - $this->assertEquals( $expected, $actual, '', 0 ); | |
| 39 | +	private function assertExactFloat(float $expected, $actual) { | |
| 40 | +		$this->assertInternalType('float', $actual); | |
| 41 | + $this->assertEquals($expected, $actual, '', 0); | |
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | 44 |  	public function testGivenOneEuro_getEuroFloatReturnsOne() { | 
| 45 | - $amount = Euro::newFromCents( 100 ); | |
| 46 | - $this->assertExactFloat( 1.0, $amount->getEuroFloat() ); | |
| 45 | + $amount = Euro::newFromCents(100); | |
| 46 | + $this->assertExactFloat(1.0, $amount->getEuroFloat()); | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 |  	public function testGivenOneCent_getEuroFloatReturnsPointZeroOne() { | 
| 50 | - $amount = Euro::newFromCents( 1 ); | |
| 51 | - $this->assertExactFloat( 0.01, $amount->getEuroFloat() ); | |
| 50 | + $amount = Euro::newFromCents(1); | |
| 51 | + $this->assertExactFloat(0.01, $amount->getEuroFloat()); | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 |  	public function testGiven33cents_getEuroFloatReturnsPointThreeThree() { | 
| 55 | - $amount = Euro::newFromCents( 33 ); | |
| 56 | - $this->assertExactFloat( 0.33, $amount->getEuroFloat() ); | |
| 55 | + $amount = Euro::newFromCents(33); | |
| 56 | + $this->assertExactFloat(0.33, $amount->getEuroFloat()); | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 |  	public function testGivenNegativeAmount_constructorThrowsException() { | 
| 60 | - $this->expectException( \InvalidArgumentException::class ); | |
| 60 | + $this->expectException(\InvalidArgumentException::class); | |
| 61 | 61 | Euro::newFromCents( -1 ); | 
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | 64 |  	public function testGivenZero_getEuroStringReturnsZeroString() { | 
| 65 | - $amount = Euro::newFromCents( 0 ); | |
| 66 | - $this->assertSame( '0.00', $amount->getEuroString() ); | |
| 65 | + $amount = Euro::newFromCents(0); | |
| 66 | +		$this->assertSame('0.00', $amount->getEuroString()); | |
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | 69 |  	public function testGivenOneEuro_getEuroStringReturnsOnePointZeroZero() { | 
| 70 | - $amount = Euro::newFromCents( 100 ); | |
| 71 | - $this->assertSame( '1.00', $amount->getEuroString() ); | |
| 70 | + $amount = Euro::newFromCents(100); | |
| 71 | +		$this->assertSame('1.00', $amount->getEuroString()); | |
| 72 | 72 | } | 
| 73 | 73 | |
| 74 | 74 |  	public function testGivenTwoEuros_getEuroStringReturnsTwoPointZeroZero() { | 
| 75 | - $amount = Euro::newFromCents( 200 ); | |
| 76 | - $this->assertSame( '2.00', $amount->getEuroString() ); | |
| 75 | + $amount = Euro::newFromCents(200); | |
| 76 | +		$this->assertSame('2.00', $amount->getEuroString()); | |
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | 79 |  	public function testGivenOneCent_getEuroStringReturnsZeroPointZeroOne() { | 
| 80 | - $amount = Euro::newFromCents( 1 ); | |
| 81 | - $this->assertSame( '0.01', $amount->getEuroString() ); | |
| 80 | + $amount = Euro::newFromCents(1); | |
| 81 | +		$this->assertSame('0.01', $amount->getEuroString()); | |
| 82 | 82 | } | 
| 83 | 83 | |
| 84 | 84 |  	public function testGivenTenCents_getEuroStringReturnsZeroPointOneZero() { | 
| 85 | - $amount = Euro::newFromCents( 10 ); | |
| 86 | - $this->assertSame( '0.10', $amount->getEuroString() ); | |
| 85 | + $amount = Euro::newFromCents(10); | |
| 86 | +		$this->assertSame('0.10', $amount->getEuroString()); | |
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | 89 |  	public function testGiven1234Cents_getEuroStringReturns12euro34() { | 
| 90 | - $amount = Euro::newFromCents( 1234 ); | |
| 91 | - $this->assertSame( '12.34', $amount->getEuroString() ); | |
| 90 | + $amount = Euro::newFromCents(1234); | |
| 91 | +		$this->assertSame('12.34', $amount->getEuroString()); | |
| 92 | 92 | } | 
| 93 | 93 | |
| 94 | 94 |  	public function testOneEuroString_getsTurnedInto100cents() { | 
| 95 | - $this->assertSame( 100, Euro::newFromString( '1.00' )->getEuroCents() ); | |
| 95 | +		$this->assertSame(100, Euro::newFromString('1.00')->getEuroCents()); | |
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | 98 |  	public function testOneCentString_getsTurnedInto1cents() { | 
| 99 | - $this->assertSame( 1, Euro::newFromString( '0.01' )->getEuroCents() ); | |
| 99 | +		$this->assertSame(1, Euro::newFromString('0.01')->getEuroCents()); | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 |  	public function testTenCentString_getsTurnedInto10cents() { | 
| 103 | - $this->assertSame( 10, Euro::newFromString( '0.10' )->getEuroCents() ); | |
| 103 | +		$this->assertSame(10, Euro::newFromString('0.10')->getEuroCents()); | |
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | 106 |  	public function testShortTenCentString_getsTurnedInto10cents() { | 
| 107 | - $this->assertSame( 10, Euro::newFromString( '0.1' )->getEuroCents() ); | |
| 107 | +		$this->assertSame(10, Euro::newFromString('0.1')->getEuroCents()); | |
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | 110 |  	public function testShortOneEuroString_getsTurnedInto100cents() { | 
| 111 | - $this->assertSame( 100, Euro::newFromString( '1' )->getEuroCents() ); | |
| 111 | +		$this->assertSame(100, Euro::newFromString('1')->getEuroCents()); | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 |  	public function testOneDecimalOneEuroString_getsTurnedInto100cents() { | 
| 115 | - $this->assertSame( 100, Euro::newFromString( '1.0' )->getEuroCents() ); | |
| 115 | +		$this->assertSame(100, Euro::newFromString('1.0')->getEuroCents()); | |
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 |  	public function testMultiDecimalOneEuroString_getsTurnedInto100cents() { | 
| 119 | - $this->assertSame( 100, Euro::newFromString( '1.00000' )->getEuroCents() ); | |
| 119 | +		$this->assertSame(100, Euro::newFromString('1.00000')->getEuroCents()); | |
| 120 | 120 | } | 
| 121 | 121 | |
| 122 | 122 |  	public function testHandlingOfLargeEuroString() { | 
| 123 | - $this->assertSame( 3133742, Euro::newFromString( '31337.42' )->getEuroCents() ); | |
| 123 | +		$this->assertSame(3133742, Euro::newFromString('31337.42')->getEuroCents()); | |
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | 126 |  	public function testEuroStringWithRoundingError_getsRoundedAppropriately() { | 
| 127 | - $this->assertSame( 101, Euro::newFromString( '1.0100000001' )->getEuroCents() ); | |
| 128 | - $this->assertSame( 101, Euro::newFromString( '1.010000009999' )->getEuroCents() ); | |
| 129 | - $this->assertSame( 101, Euro::newFromString( '1.011' )->getEuroCents() ); | |
| 130 | - $this->assertSame( 101, Euro::newFromString( '1.014' )->getEuroCents() ); | |
| 131 | - $this->assertSame( 101, Euro::newFromString( '1.0149' )->getEuroCents() ); | |
| 132 | - $this->assertSame( 102, Euro::newFromString( '1.015' )->getEuroCents() ); | |
| 133 | - $this->assertSame( 102, Euro::newFromString( '1.019' )->getEuroCents() ); | |
| 134 | - $this->assertSame( 102, Euro::newFromString( '1.0199999' )->getEuroCents() ); | |
| 135 | - $this->assertSame( 870, Euro::newFromString( '8.70' )->getEuroCents() ); | |
| 127 | +		$this->assertSame(101, Euro::newFromString('1.0100000001')->getEuroCents()); | |
| 128 | +		$this->assertSame(101, Euro::newFromString('1.010000009999')->getEuroCents()); | |
| 129 | +		$this->assertSame(101, Euro::newFromString('1.011')->getEuroCents()); | |
| 130 | +		$this->assertSame(101, Euro::newFromString('1.014')->getEuroCents()); | |
| 131 | +		$this->assertSame(101, Euro::newFromString('1.0149')->getEuroCents()); | |
| 132 | +		$this->assertSame(102, Euro::newFromString('1.015')->getEuroCents()); | |
| 133 | +		$this->assertSame(102, Euro::newFromString('1.019')->getEuroCents()); | |
| 134 | +		$this->assertSame(102, Euro::newFromString('1.0199999')->getEuroCents()); | |
| 135 | +		$this->assertSame(870, Euro::newFromString('8.70')->getEuroCents()); | |
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | 138 |  	public function testGivenNegativeAmountString_exceptionIsThrown() { | 
| 139 | - $this->expectException( \InvalidArgumentException::class ); | |
| 140 | - Euro::newFromString( '-1.00' ); | |
| 139 | + $this->expectException(\InvalidArgumentException::class); | |
| 140 | +		Euro::newFromString('-1.00'); | |
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 |  	public function testGivenStringWithComma_exceptionIsThrown() { | 
| 144 | - $this->expectException( \InvalidArgumentException::class ); | |
| 145 | - Euro::newFromString( '1,00' ); | |
| 144 | + $this->expectException(\InvalidArgumentException::class); | |
| 145 | +		Euro::newFromString('1,00'); | |
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | 148 |  	public function testGivenStringWithMultipleDots_ExceptionIsThrown() { | 
| 149 | - $this->expectException( \InvalidArgumentException::class ); | |
| 150 | - Euro::newFromString( '1.0.0' ); | |
| 149 | + $this->expectException(\InvalidArgumentException::class); | |
| 150 | +		Euro::newFromString('1.0.0'); | |
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | 153 |  	public function testGivenNonNumber_exceptionIsThrown() { | 
| 154 | - $this->expectException( \InvalidArgumentException::class ); | |
| 155 | - Euro::newFromString( '1.00abc' ); | |
| 154 | + $this->expectException(\InvalidArgumentException::class); | |
| 155 | +		Euro::newFromString('1.00abc'); | |
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | 158 |  	public function testGivenNegativeFloatAmount_exceptionIsThrown() { | 
| 159 | - $this->expectException( \InvalidArgumentException::class ); | |
| 159 | + $this->expectException(\InvalidArgumentException::class); | |
| 160 | 160 | Euro::newFromFloat( -1.00 ); | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | 163 |  	public function testOneEuroFloat_getsTurnedInto100cents() { | 
| 164 | - $this->assertSame( 100, Euro::newFromFloat( 1.0 )->getEuroCents() ); | |
| 164 | + $this->assertSame(100, Euro::newFromFloat(1.0)->getEuroCents()); | |
| 165 | 165 | } | 
| 166 | 166 | |
| 167 | 167 |  	public function testOneCentFloat_getsTurnedInto1cent() { | 
| 168 | - $this->assertSame( 1, Euro::newFromFloat( 0.01 )->getEuroCents() ); | |
| 168 | + $this->assertSame(1, Euro::newFromFloat(0.01)->getEuroCents()); | |
| 169 | 169 | } | 
| 170 | 170 | |
| 171 | 171 |  	public function testTenCentFloat_getsTurnedInto10cents() { | 
| 172 | - $this->assertSame( 10, Euro::newFromFloat( 0.1 )->getEuroCents() ); | |
| 172 | + $this->assertSame(10, Euro::newFromFloat(0.1)->getEuroCents()); | |
| 173 | 173 | } | 
| 174 | 174 | |
| 175 | 175 |  	public function testHandlingOfLargeEuroFloat() { | 
| 176 | - $this->assertSame( 3133742, Euro::newFromFloat( 31337.42 )->getEuroCents() ); | |
| 176 | + $this->assertSame(3133742, Euro::newFromFloat(31337.42)->getEuroCents()); | |
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | 179 |  	public function testFloatWithRoundingError_getsRoundedAppropriately() { | 
| 180 | - $this->assertSame( 101, Euro::newFromFloat( 1.0100000001 )->getEuroCents() ); | |
| 181 | - $this->assertSame( 101, Euro::newFromFloat( 1.010000009999 )->getEuroCents() ); | |
| 182 | - $this->assertSame( 101, Euro::newFromFloat( 1.011 )->getEuroCents() ); | |
| 183 | - $this->assertSame( 101, Euro::newFromFloat( 1.014 )->getEuroCents() ); | |
| 184 | - $this->assertSame( 101, Euro::newFromFloat( 1.0149 )->getEuroCents() ); | |
| 185 | - $this->assertSame( 102, Euro::newFromFloat( 1.015 )->getEuroCents() ); | |
| 186 | - $this->assertSame( 102, Euro::newFromFloat( 1.019 )->getEuroCents() ); | |
| 187 | - $this->assertSame( 102, Euro::newFromFloat( 1.0199999 )->getEuroCents() ); | |
| 188 | - $this->assertSame( 870, Euro::newFromFloat( 8.70 )->getEuroCents() ); | |
| 180 | + $this->assertSame(101, Euro::newFromFloat(1.0100000001)->getEuroCents()); | |
| 181 | + $this->assertSame(101, Euro::newFromFloat(1.010000009999)->getEuroCents()); | |
| 182 | + $this->assertSame(101, Euro::newFromFloat(1.011)->getEuroCents()); | |
| 183 | + $this->assertSame(101, Euro::newFromFloat(1.014)->getEuroCents()); | |
| 184 | + $this->assertSame(101, Euro::newFromFloat(1.0149)->getEuroCents()); | |
| 185 | + $this->assertSame(102, Euro::newFromFloat(1.015)->getEuroCents()); | |
| 186 | + $this->assertSame(102, Euro::newFromFloat(1.019)->getEuroCents()); | |
| 187 | + $this->assertSame(102, Euro::newFromFloat(1.0199999)->getEuroCents()); | |
| 188 | + $this->assertSame(870, Euro::newFromFloat(8.70)->getEuroCents()); | |
| 189 | 189 | } | 
| 190 | 190 | |
| 191 | 191 |  	public function testZeroEuroIntegers_isZeroCents() { | 
| 192 | - $this->assertSame( 0, Euro::newFromInt( 0 )->getEuroCents() ); | |
| 192 | + $this->assertSame(0, Euro::newFromInt(0)->getEuroCents()); | |
| 193 | 193 | } | 
| 194 | 194 | |
| 195 | 195 |  	public function testOneEuroIntegers_is100cents() { | 
| 196 | - $this->assertSame( 100, Euro::newFromInt( 1 )->getEuroCents() ); | |
| 196 | + $this->assertSame(100, Euro::newFromInt(1)->getEuroCents()); | |
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | 199 |  	public function test1337EuroIntegers_is133700cents() { | 
| 200 | - $this->assertSame( 133700, Euro::newFromInt( 1337 )->getEuroCents() ); | |
| 200 | + $this->assertSame(133700, Euro::newFromInt(1337)->getEuroCents()); | |
| 201 | 201 | } | 
| 202 | 202 | |
| 203 | 203 |  	public function testGivenNegativeIntegerAmount_exceptionIsThrown() { | 
| 204 | - $this->expectException( \InvalidArgumentException::class ); | |
| 204 | + $this->expectException(\InvalidArgumentException::class); | |
| 205 | 205 | Euro::newFromInt( -1 ); | 
| 206 | 206 | } | 
| 207 | 207 | |
| @@ -209,34 +209,34 @@ discard block | ||
| 209 | 209 | * @dataProvider euroProvider | 
| 210 | 210 | * @param Euro $euro | 
| 211 | 211 | */ | 
| 212 | -	public function testEuroEqualsItself( Euro $euro ) { | |
| 213 | - $this->assertTrue( $euro->equals( clone $euro ) ); | |
| 212 | +	public function testEuroEqualsItself(Euro $euro) { | |
| 213 | + $this->assertTrue($euro->equals(clone $euro)); | |
| 214 | 214 | } | 
| 215 | 215 | |
| 216 | 216 |  	public function euroProvider() { | 
| 217 | 217 | return [ | 
| 218 | - [ Euro::newFromCents( 0 ) ], | |
| 219 | - [ Euro::newFromCents( 1 ) ], | |
| 220 | - [ Euro::newFromCents( 99 ) ], | |
| 221 | - [ Euro::newFromCents( 100 ) ], | |
| 222 | - [ Euro::newFromCents( 9999 ) ], | |
| 218 | + [Euro::newFromCents(0)], | |
| 219 | + [Euro::newFromCents(1)], | |
| 220 | + [Euro::newFromCents(99)], | |
| 221 | + [Euro::newFromCents(100)], | |
| 222 | + [Euro::newFromCents(9999)], | |
| 223 | 223 | ]; | 
| 224 | 224 | } | 
| 225 | 225 | |
| 226 | 226 |  	public function testOneCentDoesNotEqualOneEuro() { | 
| 227 | - $this->assertFalse( Euro::newFromCents( 1 )->equals( Euro::newFromInt( 1 ) ) ); | |
| 227 | + $this->assertFalse(Euro::newFromCents(1)->equals(Euro::newFromInt(1))); | |
| 228 | 228 | } | 
| 229 | 229 | |
| 230 | 230 |  	public function testOneCentDoesNotEqualTwoCents() { | 
| 231 | - $this->assertFalse( Euro::newFromCents( 1 )->equals( Euro::newFromCents( 2 ) ) ); | |
| 231 | + $this->assertFalse(Euro::newFromCents(1)->equals(Euro::newFromCents(2))); | |
| 232 | 232 | } | 
| 233 | 233 | |
| 234 | 234 |  	public function testOneCentDoesNotEqualOneEuroAndOneCent() { | 
| 235 | - $this->assertFalse( Euro::newFromCents( 1 )->equals( Euro::newFromCents( 101 ) ) ); | |
| 235 | + $this->assertFalse(Euro::newFromCents(1)->equals(Euro::newFromCents(101))); | |
| 236 | 236 | } | 
| 237 | 237 | |
| 238 | 238 |  	public function test9001centsDoesNotEqual9000cents() { | 
| 239 | - $this->assertFalse( Euro::newFromCents( 9001 )->equals( Euro::newFromCents( 9000 ) ) ); | |
| 239 | + $this->assertFalse(Euro::newFromCents(9001)->equals(Euro::newFromCents(9000))); | |
| 240 | 240 | } | 
| 241 | 241 | |
| 242 | 242 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types = 1); | |
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Euro\Tests\Unit; | 
| 6 | 6 | |
| @@ -19,43 +19,43 @@ discard block | ||
| 19 | 19 | use TestTrait; | 
| 20 | 20 | |
| 21 | 21 |  	public function testGivenNegativeAmount_constructorThrowsException() { | 
| 22 | - $this->forAll( Generator\neg() ) | |
| 23 | -			->then( function( int $negativeInteger ) { | |
| 24 | - $this->expectException( \InvalidArgumentException::class ); | |
| 25 | - Euro::newFromCents( $negativeInteger ); | |
| 22 | + $this->forAll(Generator\neg()) | |
| 23 | +			->then(function(int $negativeInteger) { | |
| 24 | + $this->expectException(\InvalidArgumentException::class); | |
| 25 | + Euro::newFromCents($negativeInteger); | |
| 26 | 26 | } ); | 
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 |  	public function testGetCentsReturnsConstructorArgument() { | 
| 30 | - $this->limitTo( 10000 ) | |
| 31 | - ->forAll( Generator\choose( 0, 100 * 100 ) ) | |
| 32 | -			->then( function( int $unsignedInteger ) { | |
| 33 | - $amount = Euro::newFromCents( $unsignedInteger ); | |
| 34 | - $this->assertSame( $unsignedInteger, $amount->getEuroCents() ); | |
| 30 | + $this->limitTo(10000) | |
| 31 | + ->forAll(Generator\choose(0, 100 * 100)) | |
| 32 | +			->then(function(int $unsignedInteger) { | |
| 33 | + $amount = Euro::newFromCents($unsignedInteger); | |
| 34 | + $this->assertSame($unsignedInteger, $amount->getEuroCents()); | |
| 35 | 35 | } ); | 
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | 38 |  	public function testEquality() { | 
| 39 | - $this->limitTo( 10000 ) | |
| 40 | - ->forAll( Generator\choose( 0, 100 * 100 ) ) | |
| 41 | -			->then( function( int $unsignedInteger ) { | |
| 42 | - $amount = Euro::newFromCents( $unsignedInteger ); | |
| 43 | - $this->assertTrue( $amount->equals( Euro::newFromCents( $unsignedInteger ) ) ); | |
| 39 | + $this->limitTo(10000) | |
| 40 | + ->forAll(Generator\choose(0, 100 * 100)) | |
| 41 | +			->then(function(int $unsignedInteger) { | |
| 42 | + $amount = Euro::newFromCents($unsignedInteger); | |
| 43 | + $this->assertTrue($amount->equals(Euro::newFromCents($unsignedInteger))); | |
| 44 | 44 | } ); | 
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 |  	public function testNewFromString() { | 
| 48 | - $this->limitTo( 10000 ) | |
| 49 | - ->forAll( Generator\choose( 0, 100 ), Generator\choose( 0, 99 ) ) | |
| 50 | -			->then( function( int $firstInt, int $secondInt ) { | |
| 48 | + $this->limitTo(10000) | |
| 49 | + ->forAll(Generator\choose(0, 100), Generator\choose(0, 99)) | |
| 50 | +			->then(function(int $firstInt, int $secondInt) { | |
| 51 | 51 | $euroString = | 
| 52 | - (string)$firstInt | |
| 52 | + (string) $firstInt | |
| 53 | 53 | . '.' | 
| 54 | - . str_pad( (string)$secondInt, 2, '0', STR_PAD_LEFT ); | |
| 54 | + . str_pad((string) $secondInt, 2, '0', STR_PAD_LEFT); | |
| 55 | 55 | |
| 56 | 56 | $this->assertSame( | 
| 57 | 57 | $firstInt * 100 + $secondInt, | 
| 58 | - Euro::newFromString( $euroString )->getEuroCents() | |
| 58 | + Euro::newFromString($euroString)->getEuroCents() | |
| 59 | 59 | ); | 
| 60 | 60 | } ); | 
| 61 | 61 | } |