-
-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from salehhashemi1992/ci/setup-code-style-check
Implement PSR-12 Coding Standards and Add CS Check to CI Flow
- Loading branch information
Showing
76 changed files
with
918 additions
and
788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Code style | ||
|
||
on: [push, pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
phpcs: | ||
name: PHPCS | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
|
||
- name: Install dependencies | ||
run: composer update --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run script | ||
run: vendor/bin/phpcs -n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,7 @@ | |
.phan | ||
composer.lock | ||
|
||
/.phpcs-cache | ||
/phpcs.xml | ||
|
||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
<?php | ||
// A mono-alphabetic cipher is a simple substitution cipher | ||
// https://www.101computing.net/mono-alphabetic-substitution-cipher/ | ||
|
||
function monoAlphabeticCipher($key, $alphabet, $text){ | ||
|
||
$cipherText = ''; // the cipher text (can be decrypted and encrypted) | ||
|
||
if ( strlen($key) != strlen($alphabet) ) { return false; } // check if the text length matches | ||
$text = preg_replace('/[0-9]+/', '', $text); // remove all the numbers | ||
|
||
for( $i = 0; $i < strlen($text); $i++ ){ | ||
$index = strripos( $alphabet, $text[$i] ); | ||
if( $text[$i] == " " ){ $cipherText .= " "; } | ||
else{ $cipherText .= ( ctype_upper($text[$i]) ? strtoupper($key[$index]) : $key[$index] ); } | ||
} | ||
return $cipherText; | ||
} | ||
|
||
function maEncrypt($key, $alphabet, $text){ | ||
|
||
return monoAlphabeticCipher($key, $alphabet, $text); | ||
|
||
} | ||
|
||
function maDecrypt($key, $alphabet, $text){ | ||
|
||
return monoAlphabeticCipher($alphabet, $key, $text); | ||
|
||
} | ||
|
||
?> | ||
<?php | ||
|
||
// A mono-alphabetic cipher is a simple substitution cipher | ||
// https://www.101computing.net/mono-alphabetic-substitution-cipher/ | ||
|
||
function monoAlphabeticCipher($key, $alphabet, $text) | ||
{ | ||
$cipherText = ''; // the cipher text (can be decrypted and encrypted) | ||
|
||
// check if the text length matches | ||
if (strlen($key) != strlen($alphabet)) { | ||
return false; | ||
} | ||
|
||
$text = preg_replace('/[0-9]+/', '', $text); // remove all the numbers | ||
|
||
for ($i = 0; $i < strlen($text); $i++) { | ||
$index = strripos($alphabet, $text[$i]); | ||
if ($text[$i] == " ") { | ||
$cipherText .= " "; | ||
} else { | ||
$cipherText .= ( ctype_upper($text[$i]) ? strtoupper($key[$index]) : $key[$index] ); | ||
} | ||
} | ||
|
||
return $cipherText; | ||
} | ||
|
||
function maEncrypt($key, $alphabet, $text) | ||
{ | ||
return monoAlphabeticCipher($key, $alphabet, $text); | ||
} | ||
|
||
function maDecrypt($key, $alphabet, $text) | ||
{ | ||
return monoAlphabeticCipher($alphabet, $key, $text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.