Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
richan-fongdasen committed Dec 14, 2020
0 parents commit 862c540
Show file tree
Hide file tree
Showing 24 changed files with 1,220 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.
*.default text
*.example text
*.json text
*.md text
*.php text
*.txt text
*.xml text
*.yaml text
*.yml text
.gitignore text
132 changes: 132 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Build

on:
push:
branches:
- master
- release/*
- issue-*
pull_request:
branches:
- master
schedule:
- cron: 0 7 * * 1

jobs:
analysis:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4]
steps:
- uses: actions/checkout@v1
- name: Cache composer dependencies
uses: actions/cache@v2
env:
cache-name: cache-gcr-worker-laravel-latest
with:
path: ~/.composer
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run phpstan analysis
run: composer phpstan-analysis
- name: Run phpmd analysis
run: composer phpmd-analysis
- name: Run phpcpd analysis
run: vendor/bin/phpcpd --min-lines=3 --min-tokens=36 src/
laravel57:
needs: [ analysis ]
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 7.2, 7.3, 7.4 ]
steps:
- uses: actions/checkout@v1
- name: Update laravel version
run: composer require "laravel/framework:5.7.*" "orchestra/testbench:3.7.*" --no-update
- name: Remove some dev dependencies
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run the test suite
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit
laravel58:
needs: [ analysis ]
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 7.2, 7.3, 7.4 ]
steps:
- uses: actions/checkout@v1
- name: Update laravel version
run: composer require "laravel/framework:5.8.*" "orchestra/testbench:3.8.*" --no-update
- name: Remove some dev dependencies
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run the test suite
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit
laravel60:
needs: [ analysis ]
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 7.2, 7.3, 7.4 ]
steps:
- uses: actions/checkout@v1
- name: Update laravel version
run: composer require "laravel/framework:^6.0" "orchestra/testbench:^4.0" --no-update
- name: Remove some dev dependencies
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run the test suite
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit
laravel70:
needs: [ analysis ]
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 7.2, 7.3, 7.4 ]
steps:
- uses: actions/checkout@v1
- name: Update laravel version
run: composer require "laravel/framework:^7.0" "orchestra/testbench:^5.0" --no-update
- name: Remove some dev dependencies
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run the test suite
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit
laravel80:
needs: [analysis]
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4]
steps:
- uses: actions/checkout@v1
- name: Cache composer dependencies
uses: actions/cache@v2
env:
cache-name: cache-gcr-worker-laravel-latest
with:
path: ~/.composer
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run the Coverage test suite
run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit --coverage-clover=clover.xml
- name: Upload test coverage report to codecov.io
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# OS generated files
# ----------------------------------------------------------------------- #

.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db


# Vagrant files
# ----------------------------------------------------------------------- #

Vagrantfile
.vagrant
*.log


# Code Editor / IDE generated files
# ----------------------------------------------------------------------- #

.idea
*.sublime-project
*.sublime-workspace


# Composer & Vendor Files
# ----------------------------------------------------------------------- #

composer.phar
composer.lock
/vendor


# Cache Files
# ----------------------------------------------------------------------- #

*.cache


# Other files
# ----------------------------------------------------------------------- #

/coverage

151 changes: 151 additions & 0 deletions .phpmd.cleancode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0"?>

<ruleset name="Clean Code Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">

<description>
The Clean Code ruleset contains rules that enforce a clean code base. This includes rules from SOLID and object calisthenics.
</description>

<rule name="BooleanArgumentFlag"
since="1.4.0"
message="The method {0} has a boolean flag argument {1}, which is a certain sign of a Single Responsibility Principle violation."
class="PHPMD\Rule\CleanCode\BooleanArgumentFlag"
externalInfoUrl="https://phpmd.org/rules/cleancode.html#booleanargumentflag">
<description>
<![CDATA[
A boolean flag argument is a reliable indicator for a violation of
the Single Responsibility Principle (SRP). You can fix this problem
by extracting the logic in the boolean flag into its own class
or method.
]]>
</description>
<priority>1</priority>
<properties />
<example>
<![CDATA[
class Foo {
public function bar($flag = true) {
}
}
]]>
</example>
</rule>

<rule name="ElseExpression"
since="1.4.0"
message="The method {0} uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them."
class="PHPMD\Rule\CleanCode\ElseExpression"
externalInfoUrl="https://phpmd.org/rules/cleancode.html#elseexpression">
<description>
<![CDATA[
An if expression with an else branch is basically not necessary. You can rewrite the
conditions in a way that the else clause is not necessary and the code becomes simpler
to read. To achieve this, use early return statements, though you may
need to split the code it several smaller methods. For very simple assignments
you could also use the ternary operations.
]]>
</description>
<priority>1</priority>
<properties/>
<example>
<![CDATA[
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
]]>
</example>
</rule>

<rule name="IfStatementAssignment"
since="2.7.0"
message="Avoid assigning values to variables in if clauses and the like (line '{0}', column '{1}')."
class="PHPMD\Rule\CleanCode\IfStatementAssignment"
externalInfoUrl="http://phpmd.org/rules/cleancode.html#ifstatementassignment">
<description>
<![CDATA[
Assignments in if clauses and the like are considered a code smell.
Assignments in PHP return the right operand as their result.
In many cases, this is an expected behavior, but can lead
to many difficult to spot bugs, especially when the right
operand could result in zero, null or an empty string and the like.
]]>
</description>
<priority>1</priority>
<properties></properties>
<example>
<![CDATA[
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
]]>
</example>
</rule>

<rule name="DuplicatedArrayKey"
message="Duplicated array key {0}, first declared at line {1}."
class="PHPMD\Rule\CleanCode\DuplicatedArrayKey"
externalInfoUrl="http://phpmd.org/rules/cleancode.html#duplicatedarraykey">
<description>
<![CDATA[
Defining another value for the same key in an array literal overrides the previous key/value,
which makes it effectively an unused code. If it's known from the beginning that the key
will have different value, there is usually no point in defining first one.
]]>
</description>
<priority>2</priority>
<example>
<![CDATA[
function createArray() {
return [
'non-associative 0element', // not applied
0 => 'associative 0-element', // applied
false => 'associative 0-element', // applied
'foo' => 'bar', // not applied
"foo" => 'baz', // applied
];
}
]]>
</example>
</rule>

<rule name="MissingImport"
since="2.7.0"
message="Missing class import via use statement (line '{0}', column '{1}')."
class="PHPMD\Rule\CleanCode\MissingImport"
externalInfoUrl="http://phpmd.org/rules/cleancode.html#MissingImport">
<description>
<![CDATA[
Importing all external classes in a file through use statements makes them clearly visible.
]]>
</description>
<priority>1</priority>
<example>
<![CDATA[
function make() {
return new \stdClass();
}
]]>
</example>
</rule>
</ruleset>
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The MIT License (MIT)

Copyright (c) 2020 Richan Fongdasen <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
Loading

0 comments on commit 862c540

Please sign in to comment.