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:
Daniel Siepmann 2020-09-21 14:59:34 +02:00
parent c75aa1f2c0
commit 691adc00a6
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
14 changed files with 108 additions and 10 deletions

View file

@ -29,6 +29,29 @@ jobs:
- name: PHP lint
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:
runs-on: ubuntu-latest
steps:

View file

@ -27,6 +27,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"phpspec/prophecy-phpunit": "^2.0"
"phpspec/prophecy-phpunit": "^2.0",
"squizlabs/php_codesniffer": "^3.5"
}
}

53
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b9cf8f698cb3698b7ded4c56e55e8421",
"content-hash": "20a8d4087070dc229b18c15160e7bf79",
"packages": [
{
"name": "guzzlehttp/guzzle",
@ -2481,6 +2481,57 @@
],
"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",
"version": "v1.18.1",

14
phpcs.xml.dist Normal file
View 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>

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Configuration;
@ -68,7 +69,7 @@ class Settings
$this->apiKey = $apiKey;
$this->verifierID = $verifierID;
$this->user_secret = $user_secret;
$this->APIUrl = is_null($domain) ? 'https://www.skilldisplay.eu' : 'https://' . $domain;
$this->mySkillDisplayUrl = is_null($domain) ? 'https://my.skilldisplay.eu' : 'https://my.' . $domain;
$this->APIUrl = (is_null($domain)) ? 'https://www.skilldisplay.eu' : 'https://' . $domain;
$this->mySkillDisplayUrl = (is_null($domain)) ? 'https://my.skilldisplay.eu' : 'https://my.' . $domain;
}
}

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
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
$myVerificationTool = new Issuer($mySettings);
$myVerificationTool->issueVerification(193,'--skilldisplay-user-email--', VERIFICATION_SELF);
$myVerificationTool->issueVerification(193, '--skilldisplay-user-email--', VERIFICATION_SELF);

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
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
// (your Verifier Account needs the according permissions)
$myVerificationTool = new Issuer($mySettings);
$myVerificationTool->outputResponse($myVerificationTool->issueVerification(193,'--skilldisplay-user-email--', VERIFICATION_BUSINESS));
$myVerificationTool->outputResponse($myVerificationTool->issueVerification(193, '--skilldisplay-user-email--', VERIFICATION_BUSINESS));

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use SkillDisplay\PHPToolKit\Configuration\Settings;

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Example\NoSettingsRequired;

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Example\NoSettingsRequired;

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Verification;
@ -31,8 +32,7 @@ class Issuer
string $useremail,
string $vtype,
bool $isSkillSet = false
): array
{
): array {
if ($isSkillSet) {
$requestData['SkillSetId'] = $ID;
} else {

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Verification;
@ -78,7 +79,7 @@ class Link
* @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
*/
public function getVerificationLink(string $vtype, ?int $skillID = null) : string
public function getVerificationLink(string $vtype, ?int $skillID = null): string
{
$skillID = $skillID ?? $this->skillID;
@ -109,7 +110,7 @@ class Link
* @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
*/
public function getVerificationButton(string $vtype, ?int $skillID = null) : string
public function getVerificationButton(string $vtype, ?int $skillID = null): string
{
switch ($vtype) {
case VERIFICATION_EDUCATIONAL:

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Tests\Unit\Configuration;

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\PHPToolKit\Tests\Unit\Verification;