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
16 changes: 9 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# editorconfig.org
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
indent_style = space
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
charset = "utf-8"
trim_trailing_whitespace = true
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.{yaml,yml}]
indent_size = 2
46 changes: 10 additions & 36 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
# Define the line ending behavior of the different file extensions
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
* text eol=lf

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.php text
*.default text
*.ctp text
*.sql text
*.md text
*.po text
*.js text
*.css text
*.ini text
*.properties text
*.txt text
*.xml text
*.yml text
.htaccess text

# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf

# Declare files that will always have LF line endings on checkout.
*.pem eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.mo binary
*.pdf binary
*.phar binary
/.github/ export-ignore
/docs/ export-ignore
/tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.composer.lock export-ignore
/grumphp.yml export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
7 changes: 7 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
codecov:
require_ci_to_pass: yes

coverage:
range: "90...100"

comment: false
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches:
- '3.x'
pull_request:
branches:
- '*'
workflow_dispatch:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
testsuite:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3']

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
ini-values: zend.assertions = 1
coverage: pcov

- name: Composer install
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: "${{ matrix.composer-options }}"

- name: Run PHPUnit
env:
XDEBUG_MODE: coverage
run: |
if [[ '${{ matrix.php-version }}' == '8.1' ]]; 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'
uses: codecov/codecov-action@v5
with:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/vendor/
/.phpunit.result.cache

vendor/
composer.lock
composer.phar

/phpunit.xml
.phpunit.result.cache
.phpunit.cache

/coverage.xml

# OS generated files #
######################
Expand All @@ -27,11 +32,11 @@ Thumbs.db
*.tmPreferences.cache
# Eclipse
.settings/*
/.project
/.buildpath
# JetBrains, aka PHPStorm, IntelliJ IDEA
.idea/*
# NetBeans
nbproject/*
# Visual Studio Code
.vscode
# Sass preprocessor
.sass-cache/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Breton Erwane
Copyright (c) 2016 Erwane Breton. (https://erwane-breton.fr/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# CakePHP 4 Token plugin
# Token plugin for CakePHP

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
[![codecov](https://codecov.io/gh/Erwane/cakephp-token/branch/3.x/graph/badge.svg?token=Ai4gc1GP9P)](https://codecov.io/gh/Erwane/cakephp-token)
[![Build Status](https://github.com/Erwane/cakephp-token/actions/workflows/ci.yml/badge.svg?branch=3.x)](https://github.com/Erwane/cakephp-contact/actions)
[![Packagist Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-token)](https://packagist.org/packages/Erwane/cakephp-token)
[![Packagist Version](https://img.shields.io/packagist/v/Erwane/cakephp-token)](https://packagist.org/packages/Erwane/cakephp-token)

## Version map

| branch | CakePHP core | PHP min |
|--------|--------------|---------|
| 1.x | ^3.0 | PHP 7.2 |
| 2.x | ^4.0 | PHP 7.4 |
| 3.x | ^5.0 | PHP 8.1 |

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

## Installation
```bash
composer require erwane/cakephp-token:^2.0
composer require erwane/cakephp-token
bin/cake migrations migrate -p Token
```

Expand Down
40 changes: 21 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
{
"name": "erwane/cakephp-token",
"description": "Easy use token in CakePHP 4",
"description": "CakePHP plugin for tokens",
"type": "cakephp-plugin",
"keywords": ["cakephp", "token"],
"license": "MIT",
"authors": [
{
"name": "Erwane Breton",
"email": "[email protected]"
"email": "[email protected]",
"homepage": "https://erwane-breton.fr",
"role": "Developer"
}
],
"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"
},
"require": {
"php": ">=7.4.0,<9",
"php": "^8.1",
"ext-json": "*",
"cakephp/cakephp": ">=4.5,<5",
"cakephp/migrations": "^3.0"
"cakephp/cakephp": "^5.0",
"cakephp/migrations": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"cakephp/cakephp-codesniffer" : "^3.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpro/grumphp": "^1.3"
"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"
},

"autoload": {
"psr-4": {
"Token\\": "src"
"Token\\": "src/"
}
},

"autoload-dev": {
"psr-4": {
"Token\\Test\\": "tests"
"Token\\Test\\": "tests/"
}
},

"scripts": {
"post-install-cmd": [
"if [ $COMPOSER_DEV_MODE -eq 1 ]; then phpcs --config-set installed_paths vendor/cakephp/cakephp-codesniffer; fi"
],
"post-update-cmd": [
"if [ $COMPOSER_DEV_MODE -eq 1 ]; then phpcs --config-set installed_paths vendor/cakephp/cakephp-codesniffer; fi"
],
"cscheck": "vendor/bin/phpcs -p src/ tests/",
"csfix": "vendor/bin/phpcbf src/ tests/"
"csfix": "vendor/bin/phpcbf -p src/ tests/"
},

"minimum-stability": "stable",
"prefer-stable": true,
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpro/grumphp": true
}
}
Expand Down
20 changes: 10 additions & 10 deletions config/Migrations/20160720184900_CreateTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
*/
class CreateTokens extends AbstractMigration
{
public $autoId = false;
public bool $autoId = false;

/**
* Apply migrations
*
* @return void
*/
public function change()
public function change(): void
{
$table = $this->table('token_tokens');

$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('type', 'string', [ 'limit' => 64, 'null' => true, ])
->addColumn('content', 'text', [ 'null' => true, ])
->addColumn('expire', 'datetime', [ 'null' => false, ])
->addColumn('created', 'datetime', [ 'null' => false, ])
->addPrimaryKey([ 'id', ])
$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('type', 'string', ['limit' => 64, 'null' => true,])
->addColumn('content', 'text', ['null' => true,])
->addColumn('expire', 'datetime', ['null' => false,])
->addColumn('created', 'datetime', ['null' => false,])
->addPrimaryKey(['id',])
->addIndex(['scope', 'scope_id'])
->create();
}
Expand Down
8 changes: 4 additions & 4 deletions config/Migrations/20170727143023_SimplifyTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class SimplifyTokens extends AbstractMigration
{
public $autoId = false;
public bool $autoId = false;

/**
* Migration up
Expand Down Expand Up @@ -42,9 +42,9 @@ public function down()
$table = $this->table('token_tokens');

$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('type', 'string', [ 'limit' => 64, 'null' => true, ])
->addColumn('scope', 'string', ['limit' => 50, '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
2 changes: 1 addition & 1 deletion config/Migrations/20190708113200_BinaryId.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BinaryId extends AbstractMigration
*
* @return void
*/
public function up()
public function up(): void
{
$table = $this->table('token_tokens');

Expand Down
2 changes: 1 addition & 1 deletion config/Migrations/20210406113200_IdLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IdLength extends AbstractMigration
*
* @return void
*/
public function up()
public function up(): void
{
$table = $this->table('token_tokens');

Expand Down
1 change: 1 addition & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ grumphp:
phpcs:
whitelist_patterns:
- /^src\/(.*\.php)/
- /^tests\/(.*\.php)/
10 changes: 7 additions & 3 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0"?>
<ruleset name="Project">
<ruleset name="CakePHP token">
<arg name="colors"/>
<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" />
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>

<rule ref="CakePHP" />
<file>src/</file>
<file>tests/</file>

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

<rule ref="Generic.Commenting.Todo.TaskFound">
<severity>0</severity>
Expand Down
Loading
Loading