From 69e86faafc63ff8dcec72205968639cbed059168 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Sat, 23 Jul 2022 20:40:26 -0600 Subject: [PATCH] meta: add tests/Ciphers; change ciphers dir to Ciphers for consistency --- .../CaesarCipher.php | 2 +- .../morseCode.php => Ciphers/MorseCode.php | 2 +- {ciphers => Ciphers}/XORCipher.php | 0 {ciphers => Ciphers}/monoAlphabeticCipher.php | 0 tests/CipherTest.php | 22 --------------- tests/Ciphers/CiphersTest.php | 28 +++++++++++++++++++ tests/{ => Ciphers}/MorseCodeTest.php | 6 ++-- tests/CiphersTest.php | 18 ------------ 8 files changed, 33 insertions(+), 45 deletions(-) rename ciphers/caesarCipher.php => Ciphers/CaesarCipher.php (99%) rename ciphers/morseCode.php => Ciphers/MorseCode.php (99%) rename {ciphers => Ciphers}/XORCipher.php (100%) rename {ciphers => Ciphers}/monoAlphabeticCipher.php (100%) delete mode 100644 tests/CipherTest.php create mode 100755 tests/Ciphers/CiphersTest.php rename tests/{ => Ciphers}/MorseCodeTest.php (57%) delete mode 100755 tests/CiphersTest.php diff --git a/ciphers/caesarCipher.php b/Ciphers/CaesarCipher.php similarity index 99% rename from ciphers/caesarCipher.php rename to Ciphers/CaesarCipher.php index f7d1883..17adddb 100755 --- a/ciphers/caesarCipher.php +++ b/Ciphers/CaesarCipher.php @@ -37,7 +37,7 @@ function decrypt(string $text, int $shift): string if (ctype_alpha($c)) { $placeValue = ord($c) - ord(ctype_upper($c) ? 'A' : 'a'); // Getting value of character (i.e. 0-25) $placeValue = ($placeValue - $shift) % 26; // Applying decryption formula - if ($placeValue < 0) { // Handling case where remainder is negative + if ($placeValue < 0) { // Handling case where remainder is negative $placeValue += 26; } $placeValue += ord(ctype_upper($c) ? 'A' : 'a'); diff --git a/ciphers/morseCode.php b/Ciphers/MorseCode.php similarity index 99% rename from ciphers/morseCode.php rename to Ciphers/MorseCode.php index aa2673a..b50bc25 100644 --- a/ciphers/morseCode.php +++ b/Ciphers/MorseCode.php @@ -104,7 +104,7 @@ function decode(string $text): string "-----" => "0", "/" => " " ); - + $decodedText = ""; // Stores the decoded text foreach (explode(" ", $text) as $c) { // Going through each group if (array_key_exists($c, $MORSE_CODE)) { // Checks if it is a valid character diff --git a/ciphers/XORCipher.php b/Ciphers/XORCipher.php similarity index 100% rename from ciphers/XORCipher.php rename to Ciphers/XORCipher.php diff --git a/ciphers/monoAlphabeticCipher.php b/Ciphers/monoAlphabeticCipher.php similarity index 100% rename from ciphers/monoAlphabeticCipher.php rename to Ciphers/monoAlphabeticCipher.php diff --git a/tests/CipherTest.php b/tests/CipherTest.php deleted file mode 100644 index 0f630f2..0000000 --- a/tests/CipherTest.php +++ /dev/null @@ -1,22 +0,0 @@ -