-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from talis/php55_build
Refactor for build and standards, supporting PHP 5.5
- Loading branch information
Showing
51 changed files
with
2,051 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: 2.1 | ||
|
||
jobs: | ||
linting: | ||
machine: | ||
image: ubuntu-2004:202107-02 | ||
steps: | ||
- checkout | ||
- run: docker-compose run composer install | ||
- run: docker-compose run php70 ./vendor/bin/phpcs ./src | ||
test-php55: | ||
machine: | ||
image: ubuntu-2004:202107-02 | ||
steps: | ||
- checkout | ||
- run: docker-compose run composer install | ||
- run: docker-compose run phpunit55 tests/unit | ||
test-php70: | ||
machine: | ||
image: ubuntu-2004:202107-02 | ||
steps: | ||
- checkout | ||
- run: docker-compose run composer install | ||
- run: docker-compose run phpunit70 tests/unit | ||
|
||
workflows: | ||
build_and_test: | ||
jobs: | ||
- linting | ||
- test-php55: | ||
requires: | ||
- linting | ||
- test-php70: | ||
requires: | ||
- linting |
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ src/game_example/db/keys/* | |
src/game_example/db/configs/local.json | ||
.env | ||
.DS_Store | ||
.cache/composer |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: '3.7' | ||
services: | ||
composer: | ||
image: composer:latest | ||
environment: | ||
- COMPOSER_CACHE_DIR=/app/.cache/composer | ||
volumes: | ||
- .:/app | ||
restart: never | ||
php55: | ||
image: php:5.5-cli | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
restart: never | ||
php70: | ||
image: php:7.0-cli | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
restart: never | ||
phpunit55: | ||
image: php:5.5-cli | ||
restart: never | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
entrypoint: vendor/bin/phpunit | ||
phpunit70: | ||
image: php:7.0-cli | ||
restart: never | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
entrypoint: vendor/bin/phpunit |
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,47 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="LTI1p3PHPLibrary"> | ||
<config name="ignore_warnings_on_exit" value="1"/> | ||
<arg name="extensions" value="php" /> | ||
<exclude-pattern>*/src/lti/LTI_Assignments_Grades_Service.php</exclude-pattern> | ||
<exclude-pattern>*/src/lti/LTI_Course_Groups_Service.php</exclude-pattern> | ||
<!-- Generic --> | ||
<rule ref="Generic.Arrays.DisallowLongArraySyntax" /> | ||
<rule ref="Generic.Classes.OpeningBraceSameLine" /> | ||
<rule ref="Generic.Commenting.DocComment"> | ||
<!-- Allow single-line doc comments. See https://github.com/squizlabs/PHP_CodeSniffer/issues/258. --> | ||
<exclude name="Generic.Commenting.DocComment.ContentAfterOpen" /> | ||
<exclude name="Generic.Commenting.DocComment.ContentBeforeClose" /> | ||
<exclude name="Generic.Commenting.DocComment.MissingShort" /> | ||
</rule> | ||
<rule ref="Generic.Files.LineLength"> | ||
<properties> | ||
<property name="lineLimit" value="120" /> | ||
<property name="absoluteLineLimit" value="0" /> | ||
<property name="ignoreComments" value="true" /> | ||
</properties> | ||
</rule> | ||
<rule ref="Generic.Files.OneClassPerFile" /> | ||
<rule ref="Generic.Files.OneInterfacePerFile" /> | ||
<rule ref="Generic.Files.OneObjectStructurePerFile" /> | ||
<rule ref="Generic.Files.OneTraitPerFile" /> | ||
<rule ref="Generic.NamingConventions.UpperCaseConstantName" /> | ||
<rule ref="Generic.PHP.NoSilencedErrors" /> | ||
<rule ref="Generic.WhiteSpace.DisallowTabIndent" /> | ||
<!-- PEAR --> | ||
<rule ref="PEAR.NamingConventions.ValidClassName" /> | ||
<!-- Squiz --> | ||
<rule ref="Squiz.Commenting.FunctionComment"> | ||
<exclude-pattern>*/tests/*</exclude-pattern> | ||
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn" /> | ||
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital" /> | ||
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" /> | ||
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop" /> | ||
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType" /> | ||
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamName" /> | ||
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" /> | ||
<exclude name="Squiz.Commenting.InlineComment.DocBlock" /> | ||
</rule> | ||
<rule ref="Squiz.Commenting.FunctionComment.Missing"> | ||
<type>warning</type> | ||
</rule> | ||
</ruleset> |
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,46 +1,42 @@ | ||
<?php | ||
namespace IMSGlobal\LTI; | ||
|
||
class Cache { | ||
|
||
private $cache; | ||
|
||
public function get_launch_data($key) { | ||
$this->load_cache(); | ||
return $this->cache[$key]; | ||
} | ||
|
||
public function cache_launch_data($key, $jwt_body) { | ||
$this->cache[$key] = $jwt_body; | ||
$this->save_cache(); | ||
return $this; | ||
} | ||
|
||
public function cache_nonce($nonce) { | ||
$this->cache['nonce'][$nonce] = true; | ||
$this->save_cache(); | ||
return $this; | ||
} | ||
|
||
public function check_nonce($nonce) { | ||
$this->load_cache(); | ||
if (!isset($this->cache['nonce'][$nonce])) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
private function load_cache() { | ||
$cache = file_get_contents(sys_get_temp_dir() . '/lti_cache.txt'); | ||
if (empty($cache)) { | ||
file_put_contents(sys_get_temp_dir() . '/lti_cache.txt', '{}'); | ||
$this->cache = []; | ||
} | ||
$this->cache = json_decode($cache, true); | ||
} | ||
|
||
private function save_cache() { | ||
file_put_contents(sys_get_temp_dir() . '/lti_cache.txt', json_encode($this->cache)); | ||
} | ||
} | ||
?> | ||
<?php | ||
|
||
namespace IMSGlobal\LTI; | ||
|
||
interface Cache { | ||
/** | ||
* Returns the cached launch data JWT body, if it exists | ||
* | ||
* @param string $key | ||
* | ||
* @return string|null JWT body | ||
*/ | ||
public function get_launch_data($key); | ||
|
||
/** | ||
* Stores the lauch data JWT body | ||
* | ||
* @param string $key | ||
* @param string $jwt_body | ||
* | ||
* @return $this | ||
*/ | ||
public function cache_launch_data($key, $jwt_body); | ||
|
||
/** | ||
* Stores the request nonce | ||
* | ||
* @param string $nonce | ||
* | ||
* @return $this | ||
*/ | ||
public function cache_nonce($nonce); | ||
|
||
/** | ||
* Checks the validity of the nonce | ||
* | ||
* @param string $nonce | ||
* | ||
* @return boolean | ||
*/ | ||
public function check_nonce($nonce); | ||
} |
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.