Skip to content

Provide stubs #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/practice/accumulate/Accumulate.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

function accumulate(array $input, callable $accumulator)
function accumulate(array $input, callable $accumulator): array
{
// YOUR CODE GOES HERE
throw new \BadFunctionCallException("Implement the accumulate function");
}
5 changes: 5 additions & 0 deletions exercises/practice/acronym/Acronym.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function acronym(string $text): string
{
throw new \BadFunctionCallException("Implement the acronym function");
}
10 changes: 10 additions & 0 deletions exercises/practice/affine-cipher/AffineCipher.php
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
<?php

function encode(string $text, int $num1, int $num2): string
{
throw new \BadFunctionCallException("Implement the encode function");
}

function decode(string $text, int $num1, int $num2): string
{
throw new \BadFunctionCallException("Implement the decode function");
}
20 changes: 10 additions & 10 deletions exercises/practice/affine-cipher/AffineCipherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,40 +81,40 @@ public function testDecodeExercism(): void
public function testDecodeASentence(): void
{
$this->assertEquals(
decode("qdwju nqcro muwhn odqun oppmd aunwd o", 19, 16),
"anobstacleisoftenasteppingstone"
"anobstacleisoftenasteppingstone",
decode("qdwju nqcro muwhn odqun oppmd aunwd o", 19, 16)
);
}

public function testDecodeNumbers(): void
{
$this->assertEquals(
decode("odpoz ub123 odpoz ub", 25, 7),
"testing123testing"
"testing123testing",
decode("odpoz ub123 odpoz ub", 25, 7)
);
}

public function testDecodeAllTheLetters(): void
{
$this->assertEquals(
decode("swxtj npvyk lruol iejdc blaxk swxmh qzglf", 17, 33),
"thequickbrownfoxjumpsoverthelazydog"
"thequickbrownfoxjumpsoverthelazydog",
decode("swxtj npvyk lruol iejdc blaxk swxmh qzglf", 17, 33)
);
}

public function testDecodeWithNoSpacesInInput(): void
{
$this->assertEquals(
decode("swxtjnpvyklruoliejdcblaxkswxmhqzglf", 17, 33),
"thequickbrownfoxjumpsoverthelazydog"
"thequickbrownfoxjumpsoverthelazydog",
decode("swxtjnpvyklruoliejdcblaxkswxmhqzglf", 17, 33)
);
}

public function testDecodeWithTooManySpaces(): void
{
$this->assertEquals(
decode("vszzm cly yd cg qdp", 15, 16),
"jollygreengiant"
"jollygreengiant",
decode("vszzm cly yd cg qdp", 15, 16)
);
}

Expand Down
5 changes: 5 additions & 0 deletions exercises/practice/all-your-base/AllYourBase.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function rebase(int $number, array $sequence, int $base)
{
throw new \BadFunctionCallException("Implement the rebase function");
}
26 changes: 26 additions & 0 deletions exercises/practice/allergies/Allergies.php
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
<?php

class Allergies
{
public function __construct(int $score)
{
throw new \BadMethodCallException("Implement the __construct method");
}

public function isAllergicTo(Allergen $allergen): bool
{
throw new \BadMethodCallException("Implement the isAllergicTo method");
}

public function getList(): array
{
throw new \BadMethodCallException("Implement the getList method");
}
}

class Allergen
{
public static function allergenList(): array
{
throw new \BadMethodCallException("Implement the allergenList method");
}
}
5 changes: 5 additions & 0 deletions exercises/practice/anagram/Anagram.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function detectAnagrams(string $word, array $anagrams): array
{
throw new \BadFunctionCallException("Implement the detectAnagrams function");
}
5 changes: 5 additions & 0 deletions exercises/practice/armstrong-numbers/ArmstrongNumbers.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function isArmstrongNumber(int $number): bool
{
throw new \BadFunctionCallException("Implement the isArmstrongNumber function");
}
5 changes: 5 additions & 0 deletions exercises/practice/atbash-cipher/AtbashCipher.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function encode(string $text): string
{
throw new \BadFunctionCallException("Implement the encode function");
}
18 changes: 18 additions & 0 deletions exercises/practice/beer-song/BeerSong.php
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
<?php

class BeerSong
{
public function verse(int $number): string
{
throw new \BadMethodCallException("Implement the verse method");
}

public function verses(int $start, int $finish): string
{
throw new \BadMethodCallException("Implement the verses method");
}

public function lyrics(): string
{
throw new \BadMethodCallException("Implement the lyrics method");
}
}
5 changes: 5 additions & 0 deletions exercises/practice/binary-search/BinarySearch.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function find(int $needle, array $haystack): int
{
throw new \BadFunctionCallException("Implement the find function");
}
10 changes: 2 additions & 8 deletions exercises/practice/binary/Binary.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?php

// Implementation note:
// --------------------
// If the argument to parse_binary isn't a valid binary value the
// function should raise an \InvalidArgumentException
// with a meaningful error message.

function parse_binary($binary)
function parse_binary(string $binary): int
{
// YOUR CODE GOES HERE
throw new \BadFunctionCallException("Implement the parse_binary function");
}
8 changes: 8 additions & 0 deletions exercises/practice/bob/Bob.php
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
<?php

class Bob
{
public function respondTo(string $str): string
{
throw new \BadMethodCallException("Implement the toOrdinal function");
}
}
5 changes: 5 additions & 0 deletions exercises/practice/book-store/BookStore.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function total(array $items): float
{
throw new \BadFunctionCallException("Implement the total function");
}
13 changes: 13 additions & 0 deletions exercises/practice/bowling/Bowling.php
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
<?php

class Game
{
public function score(): int
{
throw new \BadMethodCallException("Implement the score function");
}

public function roll(int $pins): void
{
throw new \BadMethodCallException("Implement the roll function");
}
}
5 changes: 5 additions & 0 deletions exercises/practice/change/Change.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function findFewestCoins(array $coins, int $amount): array
{
throw new \BadFunctionCallException("Implement the findFewestCoins function");
}
8 changes: 8 additions & 0 deletions exercises/practice/clock/Clock.php
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
<?php

class Clock
{
public function __toString(): string
{
throw new \BadMethodCallException("Implement the __toString function");
}
}
5 changes: 5 additions & 0 deletions exercises/practice/collatz-conjecture/CollatzConjecture.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function steps(int $number): int
{
throw new \BadFunctionCallException("Implement the steps function");
}
5 changes: 5 additions & 0 deletions exercises/practice/connect/Connect.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function resultFor(array $lines)
{
throw new \BadFunctionCallException("Implement the resultFor method");
}
5 changes: 5 additions & 0 deletions exercises/practice/crypto-square/CryptoSquare.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function crypto_square(string $plaintext): string
{
throw new \BadFunctionCallException("Implement the crypto_square function");
}
5 changes: 5 additions & 0 deletions exercises/practice/diamond/Diamond.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function diamond(string $letter): array
{
throw new \BadFunctionCallException("Implement the diamond function");
}
18 changes: 9 additions & 9 deletions exercises/practice/diamond/DiamondTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,38 @@ public static function setUpBeforeClass(): void

public function testDegenerateCaseWithASingleARow(): void
{
$this->assertEquals(diamond("A"), ["A"]);
$this->assertEquals(["A"], diamond("A"));
}

public function testDegenerateCaseWithNoRowContaining3DistinctGroupsOfSpaces(): void
{
$this->assertEquals(
diamond("B"),
[
" A ",
"B B",
" A ",
]
],
diamond("B")
);
}

public function testSmallestNonDegenerateCaseWithOddDiamondSideLength(): void
{
$this->assertEquals(
diamond("C"),
[
" A ",
" B B ",
"C C",
" B B ",
" A ",
]
],
diamond("C")
);
}

public function testSmallestNonDegenerateCaseWithEvenDiamondSideLength(): void
{
$this->assertEquals(
diamond("D"),
[
" A ",
" B B ",
Expand All @@ -50,14 +49,14 @@ public function testSmallestNonDegenerateCaseWithEvenDiamondSideLength(): void
" C C ",
" B B ",
" A ",
]
],
diamond("D")
);
}

public function testLargestPossibleDiamond(): void
{
$this->assertEquals(
diamond("Z"),
[
" A ",
" B B ",
Expand Down Expand Up @@ -110,7 +109,8 @@ public function testLargestPossibleDiamond(): void
" C C ",
" B B ",
" A ",
]
],
diamond("Z")
);
}
}
15 changes: 15 additions & 0 deletions exercises/practice/difference-of-squares/DifferenceOfSquares.php
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
<?php

function squareOfSum(int $max): int
{
throw new \BadFunctionCallException("Implement the squareOfSum function");
}

function sumOfSquares(int $max): int
{
throw new \BadFunctionCallException("Implement the sumOfSquares function");
}

function difference(int $max): int
{
throw new \BadFunctionCallException("Implement the difference function");
}
5 changes: 5 additions & 0 deletions exercises/practice/etl/ETL.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function transform(array $input): array
{
throw new \BadFunctionCallException("Implement the transform function");
}
5 changes: 5 additions & 0 deletions exercises/practice/flatten-array/FlattenArray.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function flatten(array $input): array
{
throw new \BadFunctionCallException("Implement the flatten function");
}
5 changes: 5 additions & 0 deletions exercises/practice/gigasecond/Gigasecond.php
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?php

function from(DateTimeImmutable $date): DateTimeImmutable
{
throw new \BadFunctionCallException("Implement the from function");
}
18 changes: 18 additions & 0 deletions exercises/practice/grade-school/GradeSchool.php
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
<?php

class School
{
public function add(string $name, int $grade): void
{
throw new \BadMethodCallException("Implement the add method");
}

public function grade($grade)
{
throw new \BadMethodCallException("Implement the grade method");
}

public function studentsByGradeAlphabetical(): array
{
throw new \BadMethodCallException("Implement the studentsByGradeAlphabetical method");
}
}
10 changes: 10 additions & 0 deletions exercises/practice/grains/Grains.php
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
<?php

function square(int $number): string
{
throw new \BadFunctionCallException("Implement the square function");
}

function total(): string
{
throw new \BadFunctionCallException("Implement the total function");
}
Loading