mirror of
https://github.com/SkillDisplay/PHPToolKit.git
synced 2024-11-22 07:56:09 +01:00
Follow and validate against PSR-12
This prevents unnecessary merge conflicts in future. Also code follows a simple formatting rule set and is easier to read.
This commit is contained in:
parent
c75aa1f2c0
commit
691adc00a6
14 changed files with 108 additions and 10 deletions
23
.github/workflows/ci.yaml
vendored
23
.github/workflows/ci.yaml
vendored
|
@ -29,6 +29,29 @@ jobs:
|
||||||
- name: PHP lint
|
- name: PHP lint
|
||||||
run: "find *.php src tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l"
|
run: "find *.php src tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l"
|
||||||
|
|
||||||
|
check-cgl:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get Composer Cache Directory
|
||||||
|
id: composer-cache
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-composer-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress --no-suggest
|
||||||
|
|
||||||
|
- name: Check CGL
|
||||||
|
run: ./vendor/bin/phpcs
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.3",
|
"phpunit/phpunit": "^9.3",
|
||||||
"phpspec/prophecy-phpunit": "^2.0"
|
"phpspec/prophecy-phpunit": "^2.0",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
53
composer.lock
generated
53
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b9cf8f698cb3698b7ded4c56e55e8421",
|
"content-hash": "20a8d4087070dc229b18c15160e7bf79",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
|
@ -2481,6 +2481,57 @@
|
||||||
],
|
],
|
||||||
"time": "2020-06-26T12:18:43+00:00"
|
"time": "2020-06-26T12:18:43+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "squizlabs/php_codesniffer",
|
||||||
|
"version": "3.5.6",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||||
|
"reference": "e97627871a7eab2f70e59166072a6b767d5834e0"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e97627871a7eab2f70e59166072a6b767d5834e0",
|
||||||
|
"reference": "e97627871a7eab2f70e59166072a6b767d5834e0",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-simplexml": "*",
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"ext-xmlwriter": "*",
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/phpcs",
|
||||||
|
"bin/phpcbf"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Greg Sherwood",
|
||||||
|
"role": "lead"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
||||||
|
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||||
|
"keywords": [
|
||||||
|
"phpcs",
|
||||||
|
"standards"
|
||||||
|
],
|
||||||
|
"time": "2020-08-10T04:50:15+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.18.1",
|
"version": "v1.18.1",
|
||||||
|
|
14
phpcs.xml.dist
Normal file
14
phpcs.xml.dist
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="project">
|
||||||
|
<description>This project coding standard</description>
|
||||||
|
|
||||||
|
<file>src/</file>
|
||||||
|
<file>tests/</file>
|
||||||
|
|
||||||
|
<arg name="encoding" value="utf-8" />
|
||||||
|
<arg name="extensions" value="php" />
|
||||||
|
|
||||||
|
<rule ref="PSR12">
|
||||||
|
<exclude name="Generic.Files.LineLength.TooLong" />
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Configuration;
|
namespace SkillDisplay\PHPToolKit\Configuration;
|
||||||
|
@ -68,7 +69,7 @@ class Settings
|
||||||
$this->apiKey = $apiKey;
|
$this->apiKey = $apiKey;
|
||||||
$this->verifierID = $verifierID;
|
$this->verifierID = $verifierID;
|
||||||
$this->user_secret = $user_secret;
|
$this->user_secret = $user_secret;
|
||||||
$this->APIUrl = is_null($domain) ? 'https://www.skilldisplay.eu' : 'https://' . $domain;
|
$this->APIUrl = (is_null($domain)) ? 'https://www.skilldisplay.eu' : 'https://' . $domain;
|
||||||
$this->mySkillDisplayUrl = is_null($domain) ? 'https://my.skilldisplay.eu' : 'https://my.' . $domain;
|
$this->mySkillDisplayUrl = (is_null($domain)) ? 'https://my.skilldisplay.eu' : 'https://my.' . $domain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Example\APIKeyRequired;
|
namespace SkillDisplay\PHPToolKit\Example\APIKeyRequired;
|
||||||
|
@ -10,4 +11,4 @@ use SkillDisplay\PHPToolKit\Verification\Issuer;
|
||||||
|
|
||||||
// Automatically grant a Self-Verification (e.g.: after completing a Learning Chapter) if the SkillDisplay username is known
|
// Automatically grant a Self-Verification (e.g.: after completing a Learning Chapter) if the SkillDisplay username is known
|
||||||
$myVerificationTool = new Issuer($mySettings);
|
$myVerificationTool = new Issuer($mySettings);
|
||||||
$myVerificationTool->issueVerification(193,'--skilldisplay-user-email--', VERIFICATION_SELF);
|
$myVerificationTool->issueVerification(193, '--skilldisplay-user-email--', VERIFICATION_SELF);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Example\APIKeyRequired;
|
namespace SkillDisplay\PHPToolKit\Example\APIKeyRequired;
|
||||||
|
@ -12,4 +13,4 @@ use SkillDisplay\PHPToolKit\Verification\Issuer;
|
||||||
// In order to grant an Educational Verification you just need to exchange the constant to VERIFICATION_EDUCATIONAL
|
// In order to grant an Educational Verification you just need to exchange the constant to VERIFICATION_EDUCATIONAL
|
||||||
// (your Verifier Account needs the according permissions)
|
// (your Verifier Account needs the according permissions)
|
||||||
$myVerificationTool = new Issuer($mySettings);
|
$myVerificationTool = new Issuer($mySettings);
|
||||||
$myVerificationTool->outputResponse($myVerificationTool->issueVerification(193,'--skilldisplay-user-email--', VERIFICATION_BUSINESS));
|
$myVerificationTool->outputResponse($myVerificationTool->issueVerification(193, '--skilldisplay-user-email--', VERIFICATION_BUSINESS));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use SkillDisplay\PHPToolKit\Configuration\Settings;
|
use SkillDisplay\PHPToolKit\Configuration\Settings;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Example\NoSettingsRequired;
|
namespace SkillDisplay\PHPToolKit\Example\NoSettingsRequired;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Example\NoSettingsRequired;
|
namespace SkillDisplay\PHPToolKit\Example\NoSettingsRequired;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Verification;
|
namespace SkillDisplay\PHPToolKit\Verification;
|
||||||
|
@ -31,8 +32,7 @@ class Issuer
|
||||||
string $useremail,
|
string $useremail,
|
||||||
string $vtype,
|
string $vtype,
|
||||||
bool $isSkillSet = false
|
bool $isSkillSet = false
|
||||||
): array
|
): array {
|
||||||
{
|
|
||||||
if ($isSkillSet) {
|
if ($isSkillSet) {
|
||||||
$requestData['SkillSetId'] = $ID;
|
$requestData['SkillSetId'] = $ID;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Verification;
|
namespace SkillDisplay\PHPToolKit\Verification;
|
||||||
|
@ -78,7 +79,7 @@ class Link
|
||||||
* @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION
|
* @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION
|
||||||
* @return string URL to a Verification that a user can click, he/she will see the Verification interface and can choose a verifier
|
* @return string URL to a Verification that a user can click, he/she will see the Verification interface and can choose a verifier
|
||||||
*/
|
*/
|
||||||
public function getVerificationLink(string $vtype, ?int $skillID = null) : string
|
public function getVerificationLink(string $vtype, ?int $skillID = null): string
|
||||||
{
|
{
|
||||||
$skillID = $skillID ?? $this->skillID;
|
$skillID = $skillID ?? $this->skillID;
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ class Link
|
||||||
* @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION
|
* @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION
|
||||||
* @return string SVG Button to a Verification that a user can click, he/she will see the Verification interface and can choose a verifier
|
* @return string SVG Button to a Verification that a user can click, he/she will see the Verification interface and can choose a verifier
|
||||||
*/
|
*/
|
||||||
public function getVerificationButton(string $vtype, ?int $skillID = null) : string
|
public function getVerificationButton(string $vtype, ?int $skillID = null): string
|
||||||
{
|
{
|
||||||
switch ($vtype) {
|
switch ($vtype) {
|
||||||
case VERIFICATION_EDUCATIONAL:
|
case VERIFICATION_EDUCATIONAL:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Tests\Unit\Configuration;
|
namespace SkillDisplay\PHPToolKit\Tests\Unit\Configuration;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SkillDisplay\PHPToolKit\Tests\Unit\Verification;
|
namespace SkillDisplay\PHPToolKit\Tests\Unit\Verification;
|
||||||
|
|
Loading…
Reference in a new issue