Skip to content

Commit

Permalink
Updates (#28)
Browse files Browse the repository at this point in the history
* updates

* Remove Travis & StyleCI

* Update README.md

* Update README.md
  • Loading branch information
ciungulete authored Jun 7, 2021
1 parent 2e579c1 commit f41a45a
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 74 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check & fix styling

on: [push]

jobs:
style:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Fix style
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs --allow-risky=yes

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Commit changes
uses: stefanzweifel/[email protected]
with:
commit_message: Fix styling
branch: ${{ steps.extract_branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: tests

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
tests:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.4, 8.0]
laravel: [^7.0, ^8.0]

name: P${{ matrix.php }} - L${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, dom, intl, json, libxml, mbstring, openssl, zip
tools: composer:v2
coverage: xdebug
- name: Install dependencies
run: |
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --coverage-text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
.phpunit.result.cache
.php_cs.cache
46 changes: 46 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->notPath('vendor')
->in([
__DIR__ . '/src',
__DIR__ . '/config',
__DIR__ . '/tests',
__DIR__ . '/database',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline_array' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method', 'property',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
]
])
->setFinder($finder);

return $config;
1 change: 0 additions & 1 deletion .styleci.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Github Actions][ico-tests]][link-tests]
[![Total Downloads][ico-downloads]][link-downloads]

Easy invoice creation for Laravel. Unlike Laravel Cashier, this package is payment gateway agnostic.
Expand All @@ -27,16 +27,6 @@ Via Composer
$ composer require sander-van-hooft/laravel-invoicable
```

Next, you must install the service provider if you work with Laravel 5.4:

``` php
// config/app.php
'providers' => [
...
SanderVanHooft\Invoicable\InvoicableServiceProvider::class,
];
```

You can publish the migration with:

``` bash
Expand Down Expand Up @@ -170,11 +160,11 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio

[ico-version]: https://img.shields.io/packagist/v/sander-van-hooft/laravel-invoicable.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/sandervanhooft/laravel-invoicable/master.svg?style=flat-square
[ico-tests]: https://github.com/sandervanhooft/laravel-invoicable/workflows/tests/badge.svg
[ico-downloads]: https://img.shields.io/packagist/dt/sander-van-hooft/laravel-invoicable.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/sander-van-hooft/laravel-invoicable
[link-travis]: https://travis-ci.org/sandervanhooft/laravel-invoicable
[link-tests]: https://github.com/sandervanhooft/laravel-invoicable/actions
[link-downloads]: https://packagist.org/packages/sander-van-hooft/laravel-invoicable
[link-author]: https://github.com/sandervanhooft
[link-contributors]: ../../contributors
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.4 || ^8.0",
"ext-intl": "*",
"dompdf/dompdf": "^0.8.0",
"illuminate/support": "^5.8|^6.0|^7.0|^8.0",
"nesbot/carbon": "^1.22|^2.0"
"dompdf/dompdf": "^1.0",
"illuminate/support": "^7.0 || ^8.0",
"nesbot/carbon": "^2.0"
},
"require-dev": {
"graham-campbell/testbench": "^5.2",
"phpunit/phpunit": "^7.5|^8.3",
"squizlabs/php_codesniffer": "^3.4"
"graham-campbell/testbench": "^5.6",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.4",
"friendsofphp/php-cs-fixer": "^2.18"
},
"autoload": {
"psr-4": {
Expand All @@ -45,8 +46,7 @@
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
"format": "./vendor/bin/php-cs-fixer fix --allow-risky=yes"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion config/invoicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
'default_currency' => 'EUR',
'default_status' => 'concept',
'locale' => 'nl_NL',
];
];
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateInvoicesTables extends Migration
{
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
Expand All @@ -19,4 +18,4 @@
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion src/InvoicableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function boot()
], 'config');

// Publish migrations
$this->publishes([
$this->publishes([
__DIR__.'/../database/migrations/2017_06_17_163005_create_invoices_tables.php'
=> database_path('migrations/2017_06_17_163005_create_invoices_tables.php'),
], 'migrations');
Expand Down
4 changes: 4 additions & 0 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function addAmountExclTax($amount, $description, $taxPercentage = 0)
'tax' => $tax,
'tax_percentage' => $taxPercentage,
]);

return $this->recalculate();
}

Expand All @@ -53,6 +54,7 @@ public function addAmountInclTax($amount, $description, $taxPercentage = 0)
'tax' => $amount - $amount / (1 + $taxPercentage),
'tax_percentage' => $taxPercentage,
]);

return $this->recalculate();
}

Expand All @@ -65,6 +67,7 @@ public function recalculate()
$this->total = $this->lines()->sum('amount');
$this->tax = $this->lines()->sum('tax');
$this->save();

return $this;
}

Expand Down Expand Up @@ -104,6 +107,7 @@ public function pdf(array $data = [])
$dompdf = new Dompdf;
$dompdf->loadHtml($this->view($data)->render());
$dompdf->render();

return $dompdf->output();
}

Expand Down
1 change: 0 additions & 1 deletion src/InvoiceLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SanderVanHooft\Invoicable;

use Illuminate\Database\Eloquent\Model;
use SanderVanHooft\Invoicable\Invoice;

class InvoiceLine extends Model
{
Expand Down
2 changes: 2 additions & 0 deletions src/InvoiceReferenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class InvoiceReferenceGenerator
public static function generate()
{
$date = Carbon::now();

return $date->format('Y-m-d') . '-' . self::generateRandomCode();
}

protected static function generateRandomCode()
{
$pool = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';

return substr(str_shuffle(str_repeat($pool, 6)), 0, 6);
}
}
12 changes: 6 additions & 6 deletions src/MoneyFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class MoneyFormatter
{

/**
* The current currency.
*
Expand Down Expand Up @@ -33,6 +32,7 @@ public function __construct($currency = 'EUR', $locale = 'nl_NL')
public function format($amount)
{
$formatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);

return (string) $formatter->formatCurrency($amount / 100, $this->currency);
}

Expand Down Expand Up @@ -64,11 +64,11 @@ public function getCurrency()
return (string) $this->currency;
}

/**
* Sets the current currency
* @param $currency The currency (i.e. 'EUR')
* @return Void
*/
/**
* Sets the current currency
* @param $currency The currency (i.e. 'EUR')
* @return Void
*/
public function setCurrency(string $currency)
{
$this->currency = $currency;
Expand Down
6 changes: 1 addition & 5 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SanderVanHooft\Invoicable;

use GrahamCampbell\TestBench\AbstractPackageTestCase;
use SanderVanHooft\Invoicable\InvoicableServiceProvider;

class AbstractTestCase extends AbstractPackageTestCase
{
Expand All @@ -22,12 +21,9 @@ protected function getEnvironmentSetUp($app)

/**
* Get the service provider class.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return string
*/
protected function getServiceProviderClass($app)
protected function getServiceProviderClass()
{
return InvoicableServiceProvider::class;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/CreateTestModelsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SanderVanHooft\Invoicable;

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTestModelsTable extends Migration
{
Expand Down
Loading

0 comments on commit f41a45a

Please sign in to comment.