Skip to content

Commit decd9cc

Browse files
committed
Fix solution
1 parent 76b3a2b commit decd9cc

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
if (str_starts_with($_SERVER['REQUEST_URI'], '/forbidden')) {
4-
echo 'Welcome!';
5-
} else {
64
throw new InvalidArgumentException('Access denied!');
5+
} else {
6+
echo 'Welcome!';
77
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
echo str_starts_with($_SERVER['REQUEST_URI'], '/forbidden')
4-
? 'Welcome!'
5-
: throw new InvalidArgumentException('Access denied!');
4+
? throw new InvalidArgumentException('Access denied!')
5+
: 'Welcome!';

src/Exercise/ThrowAnExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function check(Input $input): ResultInterface
7878
return Failure::fromNameAndReason($this->getName(), 'No ternary statement found');
7979
}
8080

81-
if (!$ternary->else instanceof Throw_) {
81+
if (!$ternary->if instanceof Throw_) {
8282
return Failure::fromNameAndReason($this->getName(), 'Ternary does not make use of throw expression');
8383
}
8484

test/Exercise/ThrowAnExpressionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public function testThrowingWrongException(): void
2929
$this->assertVerifyWasNotSuccessful();
3030

3131
$output = $this->getOutputResult();
32-
33-
self::assertInstanceOf(Success::class, $output->getResults()[0]);
34-
self::assertInstanceOf(GenericFailure::class, $output->getResults()[1]);
32+
33+
self::assertInstanceOf(GenericFailure::class, $output->getResults()[0]);
34+
self::assertInstanceOf(Success::class, $output->getResults()[1]);
3535

3636
self::assertMatchesRegularExpression(
3737
'/Fatal error: Uncaught Exception: Access denied!/',
38-
$output->getResults()[1]->getReason()
38+
$output->getResults()[0]->getReason()
3939
);
4040

4141
$this->assertOutputWasIncorrect();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
if (str_starts_with($_SERVER['REQUEST_URI'], '/forbidden')) {
4-
echo 'Welcome!';
5-
} else {
64
throw new InvalidArgumentException('Access denied!');
5+
} else {
6+
echo 'Welcome!';
77
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
$result = str_starts_with($_SERVER['REQUEST_URI'], '/forbidden')
4-
? 'Welcome!'
5-
: 'Access denied!';
4+
? 'Access denied!'
5+
: 'Welcome!';
66

77
echo $result;
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
echo str_starts_with($_SERVER['REQUEST_URI'], '/forbidden')
4-
? 'Welcome!'
5-
: throw new InvalidArgumentException('Access denied!');
4+
? throw new InvalidArgumentException('Access denied!')
5+
: 'Welcome!';
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
echo str_starts_with($_SERVER['REQUEST_URI'], '/forbidden')
4-
? 'Welcome!'
5-
: throw new Exception('Access denied!');
4+
? throw new Exception('Access denied!')
5+
: 'Welcome!';

0 commit comments

Comments
 (0)