Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM php:8.2-cli-alpine AS final

ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN install-php-extensions ctype curl intl json mbstring xml xdebug

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1

WORKDIR /var/www/html

# keep container up
CMD ["php", "-S", "0.0.0.0:80", "-t", "./"]
7 changes: 3 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/.docker/ export-ignore
/.github/ export-ignore
/docs/ export-ignore
/tests/ export-ignore
.editorconfig export-ignore
/.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.composer.lock export-ignore
/grumphp.yml export-ignore
/docker-compose.yaml export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
6 changes: 6 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# These are supported funding model platforms

github: [Erwane]
liberapay: erwane
buy_me_a_coffee: erwane
thanks_dev: gh/erwane
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3']
php-version: ['8.3', '8.5']

steps:
- uses: actions/checkout@v4
Expand All @@ -41,15 +41,15 @@ jobs:
env:
XDEBUG_MODE: coverage
run: |
if [[ '${{ matrix.php-version }}' == '8.1' ]]; then
if [[ '${{ matrix.php-version }}' == '8.3' ]]; then
export CODECOVERAGE=1
vendor/bin/phpunit --display-warnings --display-incomplete --coverage-clover=coverage.xml
else
vendor/bin/phpunit --display-phpunit-deprecations --display-deprecations --display-warnings
fi

- name: Submit code coverage
if: matrix.php-version == '8.1'
if: matrix.php-version == '8.3'
uses: codecov/codecov-action@v5
with:
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| 3.x | ^5.0 | PHP 8.1 |

## Description
This is a really "simple to use" CakePHP plugin for generating and reading temporaries tokens
This is a really "easy to use" CakePHP plugin for generating and reading temporaries tokens

## Installation
```bash
Expand Down
20 changes: 9 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "erwane/cakephp-token",
"description": "CakePHP plugin for tokens",
"type": "cakephp-plugin",
"keywords": ["cakephp", "token"],
"keywords": [
"cakephp",
"token"
],
"license": "MIT",
"authors": [
{
Expand All @@ -14,22 +17,19 @@
],
"support": {
"issues": "https://github.com/Erwane/cakephp-token/issues",
"source": "https://github.com/Erwane/cakephp-token",
"docs": "https://github.com/Erwane/cakephp-token/blob/master/README.md"
"source": "https://github.com/Erwane/cakephp-token"
},
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"cakephp/cakephp": "^5.0",
"cakephp/migrations": "^4.0"
"cakephp/cakephp": "^5.3",
"cakephp/migrations": "^5.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^5.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpro/grumphp": "^2.0",
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
"phpunit/phpunit": "^11.1.3"
},

"autoload": {
"psr-4": {
"Token\\": "src/"
Expand All @@ -40,12 +40,10 @@
"Token\\Test\\": "tests/"
}
},

"scripts": {
"cscheck": "vendor/bin/phpcs -p src/ tests/",
"csfix": "vendor/bin/phpcbf -p src/ tests/"
},

"minimum-stability": "stable",
"prefer-stable": true,
"config": {
Expand Down
14 changes: 9 additions & 5 deletions config/Migrations/20160720184900_CreateTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/
declare(strict_types=1);

use Migrations\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
use Migrations\BaseMigration;
use Migrations\Db\Adapter\MysqlAdapter;

/**
* Class CreateTokens
*/
class CreateTokens extends AbstractMigration
class CreateTokens extends BaseMigration
{
public bool $autoId = false;

Expand All @@ -24,9 +24,13 @@ public function change(): void
{
$table = $this->table('token_tokens');

$table->addColumn('id', 'string', ['limit' => 12, 'null' => false,])
$table
->addColumn('id', 'string', ['limit' => 12, 'null' => false,])
->addColumn('scope', 'string', ['limit' => 50, 'default' => null, 'null' => true,])
->addColumn('scope_id', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_REGULAR, 'default' => null, 'null' => true,])
->addColumn(
'scope_id', 'integer',
['signed' => false, 'limit' => MysqlAdapter::INT_REGULAR, 'default' => null, 'null' => true,],
)
->addColumn('type', 'string', ['limit' => 64, 'null' => true,])
->addColumn('content', 'text', ['null' => true,])
->addColumn('expire', 'datetime', ['null' => false,])
Expand Down
11 changes: 7 additions & 4 deletions config/Migrations/20170727143023_SimplifyTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/
declare(strict_types=1);

use Migrations\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
use Migrations\BaseMigration;
use Migrations\Db\Adapter\MysqlAdapter;

/**
* Class SimplifyTokens
*/
class SimplifyTokens extends AbstractMigration
class SimplifyTokens extends BaseMigration
{
public bool $autoId = false;

Expand Down Expand Up @@ -43,7 +43,10 @@ public function down()

$table
->addColumn('scope', 'string', ['limit' => 50, 'default' => null, 'null' => true,])
->addColumn('scope_id', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_REGULAR, 'default' => null, 'null' => true,])
->addColumn(
'scope_id', 'integer',
['signed' => false, 'limit' => MysqlAdapter::INT_REGULAR, 'default' => null, 'null' => true,],
)
->addColumn('type', 'string', ['limit' => 64, 'null' => true,])
->addIndex(['scope', 'scope_id'])
->save();
Expand Down
4 changes: 2 additions & 2 deletions config/Migrations/20190708113200_BinaryId.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/
declare(strict_types=1);

use Migrations\AbstractMigration;
use Migrations\BaseMigration;

/**
* Class BinaryId
*/
class BinaryId extends AbstractMigration
class BinaryId extends BaseMigration
{
/**
* Apply migrations
Expand Down
4 changes: 2 additions & 2 deletions config/Migrations/20210406113200_IdLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/
declare(strict_types=1);

use Migrations\AbstractMigration;
use Migrations\BaseMigration;

/**
* Class BinaryId
*/
class IdLength extends AbstractMigration
class IdLength extends BaseMigration
{
/**
* Apply migrations
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
php:
build:
./.docker/
volumes:
- ".:/var/www/html"
13 changes: 6 additions & 7 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
<arg name="encoding=UTF-8"/>
<arg name="report=full"/>
<arg name="parallel=8"/>
<arg name="severity=1"/>
<arg name="extensions=php"/>

<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>
<file>./src</file>
<file>./tests</file>

<file>src/</file>
<file>tests/</file>

<rule ref="CakePHP"/>
<arg value="s"/>
<rule ref="CakePHP" />

<rule ref="Generic.Commenting.Todo.CommentFound">
<severity>0</severity>
</rule>
<rule ref="Generic.Commenting.Todo.TaskFound">
<severity>0</severity>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Table/TokensTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function read(string $id): ?Token
public function generate(
array $content = [],
DateTimeInterface|string|null $expire = null,
int $tokenLength = 8
int $tokenLength = 8,
): string {
$entity = $this->newEntity([
'id' => $this->_uniqId($tokenLength),
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php → src/TokenPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
*
* @package Token
*/
class Plugin extends BasePlugin
class TokenPlugin extends BasePlugin
{
}
4 changes: 3 additions & 1 deletion tests/TestCase/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function testMigrations()
'length' => null,
'null' => false,
'default' => null,
'onUpdate' => null,
'precision' => null,
'comment' => null,
],
Expand All @@ -88,14 +89,15 @@ public function testMigrations()
'length' => null,
'null' => false,
'default' => null,
'onUpdate' => null,
'precision' => null,
'comment' => null,
],
];

foreach ($columns as $name => $expected) {
$column = $schema->getColumn($name);
$this->assertSame($column, $expected, "Field `$name`: comparison fail");
$this->assertEquals($column, $expected, "Field `$name`: comparison fail");
}
}
}
Loading