Skip to content

Commit

Permalink
Added initial Verifier library
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wright <[email protected]>
  • Loading branch information
betterthanclay committed Jun 19, 2024
1 parent 9c402a9 commit c2e1af8
Show file tree
Hide file tree
Showing 21 changed files with 1,315 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
block_comment_start = /*
block_comment = *
block_comment_end = */

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.editorconfig export-ignore
.gitattributes export-ignore
.github/ export-ignore
.gitignore export-ignore
CHANGELOG.md export-ignore
ecs.php export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
docs/ export-ignore
tests/ export-ignore
130 changes: 130 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: "Integrate"

on:
push:
branches:
- "develop"
pull_request: null

env:
PHP_EXTENSIONS: "intl"

jobs:
file_consistency:
name: "1️⃣ File consistency"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

- name: "Checkout code"
uses: "actions/checkout@v4"

- name: Install Effigy
run: |
composer global config --no-plugins allow-plugins.phpstan/extension-installer true
composer global require decodelabs/effigy
- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"

- name: "Check file permissions"
run: |
composer global exec effigy check-executable-permissions
- name: "Check exported files"
run: |
composer global exec effigy check-git-exports
- name: "Find non-printable ASCII characters"
run: |
composer global exec effigy check-non-ascii
- name: "Check source code for syntax errors"
run: |
composer global exec effigy lint
static_analysis:
name: "3️⃣ Static Analysis"
needs:
- "file_consistency"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

- name: "Checkout code"
uses: "actions/checkout@v4"

- name: Install Effigy
run: |
composer global config --no-plugins allow-plugins.phpstan/extension-installer true
composer global require decodelabs/effigy
- name: "Validate Composer configuration"
run: "composer validate --strict"

- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"

- name: "Execute static analysis"
run: |
composer global exec effigy analyze -- --headless
coding_standards:
name: "4️⃣ Coding Standards"
needs:
- "file_consistency"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Check EditorConfig configuration"
run: "test -f .editorconfig"

- name: "Check adherence to EditorConfig"
uses: "greut/eclint-action@v0"

- name: Install Effigy
run: |
composer global config --no-plugins allow-plugins.phpstan/extension-installer true
composer global require decodelabs/effigy
- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"

- name: "Check coding style"
run: |
composer global exec effigy format -- --headless
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/vendor
composer.phar
composer.lock
.DS_Store
Thumbs.db
/phpunit.xml
/.idea
/.env
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## v0.1.0 (2024-06-19)
* Built initial implementation
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Scrutiny

[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/scrutiny?style=flat)](https://packagist.org/packages/decodelabs/scrutiny)
[![Latest Version](https://img.shields.io/packagist/v/decodelabs/scrutiny.svg?style=flat)](https://packagist.org/packages/decodelabs/scrutiny)
[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/scrutiny.svg?style=flat)](https://packagist.org/packages/decodelabs/scrutiny)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/scrutiny/integrate.yml?branch=develop)](https://github.com/decodelabs/scrutiny/actions/workflows/integrate.yml)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat)](https://github.com/phpstan/phpstan)
[![License](https://img.shields.io/packagist/l/decodelabs/scrutiny?style=flat)](https://packagist.org/packages/decodelabs/scrutiny)

### Unified human check controls

Scrutiny provides ...

_Get news and updates on the [DecodeLabs blog](https://blog.decodelabs.com)._

---

## Installation

Install via Composer:

```bash
composer require decodelabs/scrutiny
```

## Usage

Coming soon...

## Licensing

Scrutiny is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.
45 changes: 45 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "decodelabs/scrutiny",
"description": "Unified human check controls",
"type": "library",
"keywords": [ ],
"license": "MIT",
"authors": [ {
"name": "Tom Wright",
"email": "[email protected]"
} ],
"require": {
"php": "^8.1",

"decodelabs/archetype": "^0.3.5",
"decodelabs/coercion": "^0.2.8",
"decodelabs/compass": "^0.1.7",
"decodelabs/exceptional": "^0.4.5",
"decodelabs/glitch-support": "^0.4.6",
"decodelabs/hydro": "^0.1.3",
"decodelabs/slingshot": "^0.1.9",
"decodelabs/veneer": "^0.10.25",

"symfony/polyfill-php82": "^1.29"
},
"require-dev": {
"decodelabs/phpstan-decodelabs": "^0.6.8",
"decodelabs/dovetail": "^0.2.5"
},
"autoload": {
"psr-4": {
"DecodeLabs\\Scrutiny\\": "src/Scrutiny"
},
"classmap": [
"src/Dovetail/"
],
"files": [
"src/Scrutiny/Context.php"
]
},
"extra": {
"branch-alias": {
"dev-develop": "0.1.x-dev"
}
}
}
14 changes: 14 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

// ecs.php

declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
->withPaths([__DIR__.'/src'])
->withPreparedSets(
cleanCode: true,
psr12: true
);
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
paths:
- src
level: max
52 changes: 52 additions & 0 deletions src/Dovetail/Config/Scrutiny.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* @package Scrutiny
* @license http://opensource.org/licenses/MIT
*/

declare(strict_types=1);

namespace DecodeLabs\Dovetail\Config;

use DecodeLabs\Dovetail\Config;
use DecodeLabs\Dovetail\ConfigTrait;
use DecodeLabs\Scrutiny\Config as ConfigInterface;

class Scrutiny implements Config, ConfigInterface
{
use ConfigTrait;

public static function getDefaultValues(): array
{
return [
'VerifierName' => [
'enabled' => false,
'siteKey' => '--siteKey--',
'secret' => "{{envString('VERIFIER_SECRET')}}",
]
];
}

public function getFirstEnabledVerifier(): ?string
{
foreach ($this->data as $name => $settings) {
if ($settings->enabled->as('bool', [
'default' => true
])) {
return (string)$name;
}
}

return null;
}

/**
* @return array<string, mixed>
*/
public function getSettingsFor(
string $verifierName
): array {
return $this->data->{$verifierName}->toArray();
}
}
22 changes: 22 additions & 0 deletions src/Scrutiny/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @package Scrutiny
* @license http://opensource.org/licenses/MIT
*/

declare(strict_types=1);

namespace DecodeLabs\Scrutiny;

interface Config
{
public function getFirstEnabledVerifier(): ?string;

/**
* @return array<string, mixed>
*/
public function getSettingsFor(
string $verifierName
): array;
}
Loading

0 comments on commit c2e1af8

Please sign in to comment.