From a62c22030ea36cabc1f6bf264d49bfef99dff383 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 12 Jul 2020 16:54:11 +0100 Subject: [PATCH] Pangram --- README.md | 1 + composer.json | 5 ++++- src/Pangram.php | 14 ++++++++++++++ tests/PangramTest.php | 19 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/Pangram.php create mode 100644 tests/PangramTest.php diff --git a/README.md b/README.md index bd6dca0..d46071f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Includes: - **Bob**: returns different responses based on input. - **Bowling**: calculate the score for a game of bowling. - **Grade School**: given students' names along with the grade that they are in, create a roster for the school. +- **Pangram** - determine if a sentence is a pangram (every letter of the alphabet is used at least once). - **Rock, paper, scissors** - **Roman numerals**: convert a number into its roman numeral value. diff --git a/composer.json b/composer.json index 709c257..3b6e4a4 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,10 @@ "phpunit/phpunit": "^9.0" }, "autoload": { - "files": ["src/FlattenArray.php"], + "files": [ + "src/FlattenArray.php", + "src/Pangram.php" + ], "psr-4": { "App\\": "src/" } diff --git a/src/Pangram.php b/src/Pangram.php new file mode 100644 index 0000000..67811d5 --- /dev/null +++ b/src/Pangram.php @@ -0,0 +1,14 @@ + $letter != ' '); + + return count(array_unique($filtered)) == 26; +} diff --git a/tests/PangramTest.php b/tests/PangramTest.php new file mode 100644 index 0000000..ab8d041 --- /dev/null +++ b/tests/PangramTest.php @@ -0,0 +1,19 @@ +with([ + [ + 'input' => 'hello word', + 'expected' => false, + ], + [ + 'input' => 'The quick brown fox jumps over the lazy dog', + 'expected' => true, + ] +]); \ No newline at end of file