From cd486a4fd6b11d7afe717c4e0873a8afa82c8f97 Mon Sep 17 00:00:00 2001 From: MohamedSabil83 Date: Thu, 23 Dec 2021 04:29:10 +0300 Subject: [PATCH 1/4] Refactor using spatie/laravel-package-tools --- .editorconfig | 6 +-- .gitattributes | 12 ++++- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 .github/FUNDING.yml | 1 + .github/ISSUE_TEMPLATE/config.yml | 14 +++++ .github/SECURITY.md | 3 ++ .github/dependabot.yml | 12 +++++ .github/workflows/dependabot-auto-merge.yml | 32 ++++++++++++ .github/workflows/php-cs-fixer.yml | 23 ++++++++ .github/workflows/phpstan.yml | 26 ++++++++++ .github/workflows/run-tests.yml | 47 +++++++++++++++++ .github/workflows/update-changelog.yml | 28 ++++++++++ .gitignore | 12 ++++- .php_cs.dist.php | 40 ++++++++++++++ .scrutinizer.yml | 18 ------- .styleci.yml | 4 -- .travis.yml | 22 -------- CHANGELOG.md | 2 +- LICENSE.md | 12 ++--- composer.json | 37 ++++++++----- phpstan-baseline.neon | 0 phpstan.neon.dist | 11 ++++ phpunit.xml.dist | 52 +++++++++++-------- .../InteractsWithDates.php} | 15 +++--- src/Facades/LaravelHijrian.php | 17 ++++++ src/LaravelHijrian.php | 15 ++++-- src/LaravelHijrianFacade.php | 18 ------- src/LaravelHijrianServiceProvider.php | 26 +++------- tests/Pest.php | 5 ++ tests/TestCase.php | 24 ++------- 30 files changed, 374 insertions(+), 160 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/SECURITY.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot-auto-merge.yml create mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .github/workflows/phpstan.yml create mode 100644 .github/workflows/run-tests.yml create mode 100644 .github/workflows/update-changelog.yml create mode 100644 .php_cs.dist.php delete mode 100644 .scrutinizer.yml delete mode 100644 .styleci.yml delete mode 100644 .travis.yml create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist rename src/{HijrianTrait.php => Concerns/InteractsWithDates.php} (98%) create mode 100644 src/Facades/LaravelHijrian.php delete mode 100644 src/LaravelHijrianFacade.php create mode 100644 tests/Pest.php diff --git a/.editorconfig b/.editorconfig index cd8eb86..a7c44dd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,3 @@ -; This file is for unifying the coding style for different editors and IDEs. -; More information at http://editorconfig.org - root = true [*] @@ -13,3 +10,6 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index bb6265e..9e9519b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,10 +2,18 @@ # https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html # Ignore all test and documentation with "export-ignore". +/.github export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.travis.yml export-ignore /phpunit.xml.dist export-ignore -/.scrutinizer.yml export-ignore +/art export-ignore +/docs export-ignore /tests export-ignore /.editorconfig export-ignore +/.php_cs.dist.php export-ignore +/psalm.xml export-ignore +/psalm.xml.dist export-ignore +/testbench.yaml export-ignore +/UPGRADING.md export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..157d561 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ["https://paypal.me/technolizer"] diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..37adb54 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a question + url: https://github.com/mohamedsabil83/laravel-hijrian/discussions/new?category=q-a + about: Ask the community for help + - name: Request a feature + url: https://github.com/mohamedsabil83/laravel-hijrian/discussions/new?category=ideas + about: Share ideas for new features + - name: Report a security issue + url: https://github.com/mohamedsabil83/laravel-hijrian/security/policy + about: Learn how to notify us for sensitive bugs + - name: Report a bug + url: https://github.com/mohamedsabil83/laravel-hijrian/issues/new + about: Report a reproducable bug diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..23dd1c3 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +If you discover any security related issues, please email me@mohamedsabil83.com instead of using the issue tracker. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..30c8a49 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..399ef82 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: dependabot-auto-merge +on: pull_request_target + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.1.1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge Dependabot PRs for semver-minor updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Auto-merge Dependabot PRs for semver-patch updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..f55d1fa --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: Check & fix styling + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..19d6402 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,26 @@ +name: PHPStan + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v1 + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..041bf5d --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,47 @@ +name: run-tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.0] + laravel: [8.*] + stability: [prefer-lowest, prefer-stable] + include: + - laravel: 8.* + testbench: ^6.23 + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/pest diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 0000000..fa56639 --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,28 @@ +name: "Update Changelog" + +on: + release: + types: [released] + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md diff --git a/.gitignore b/.gitignore index e45efd8..9a43686 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,14 @@ +.idea +.php_cs +.php_cs.cache +.phpunit.result.cache build composer.lock +coverage docs +phpunit.xml +phpstan.neon +testbench.yaml vendor -coverage -.phpunit.result.cache \ No newline at end of file +node_modules +.php-cs-fixer.cache diff --git a/.php_cs.dist.php b/.php_cs.dist.php new file mode 100644 index 0000000..8d8a790 --- /dev/null +++ b/.php_cs.dist.php @@ -0,0 +1,40 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => 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' => 'one', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 1165e72..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,18 +0,0 @@ -filter: - excluded_paths: [tests/*] - -checks: - php: - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index f4d3cbc..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,4 +0,0 @@ -preset: laravel - -disabled: - - single_class_element_per_statement diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7a96344..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - matrix: - - COMPOSER_FLAGS="--prefer-lowest" - - COMPOSER_FLAGS="" - -before_script: - - travis_retry composer self-update - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source - -script: - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c7fc1..3f191d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to `laravel-hijrian` will be documented in this file +All notable changes to `laravel-hijrian` will be documented in this file. ## v2.0.0 - 2020-05-08 diff --git a/LICENSE.md b/LICENSE.md index 9dc7429..a72ac7e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ -MIT License +The MIT License (MIT) -Copyright (c) Mohamed Sabil +Copyright (c) mohamedsabil83 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,13 +9,13 @@ 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 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. \ No newline at end of file +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/composer.json b/composer.json index 9a37ce1..ac3ee80 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ ], "homepage": "https://github.com/mohamedsabil83/laravel-hijrian", "license": "MIT", - "type": "library", "authors": [ { "name": "Mohamed Sabil", @@ -21,13 +20,21 @@ } ], "require": { - "php": "^7.1|^8.0", - "illuminate/support": "^5.8|^6.0|^7.0|^8.0", - "nesbot/carbon": "^2.0" + "php": "^7.4|^8.0", + "spatie/laravel-package-tools": "^1.9.2", + "illuminate/contracts": "^5.8|^6.0|^7.0|^8.0" }, "require-dev": { - "orchestra/testbench": "^3.8|^4.0|^5.0|^6.0", - "phpunit/phpunit": "^7.5|^8.0|^9.3" + "nunomaduro/collision": "^5.10", + "nunomaduro/larastan": "^1.0", + "orchestra/testbench": "^6.22", + "pestphp/pest": "^1.21", + "pestphp/pest-plugin-laravel": "^1.1", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5", + "spatie/laravel-ray": "^1.26" }, "autoload": { "psr-4": { @@ -40,12 +47,16 @@ } }, "scripts": { - "test": "vendor/bin/phpunit", - "test-coverage": "vendor/bin/phpunit --coverage-html coverage" - + "analyse": "vendor/bin/phpstan analyse", + "test": "vendor/bin/pest", + "test-coverage": "vendor/bin/pest coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true, + "pestphp/pest-plugin": true + } }, "extra": { "laravel": { @@ -53,8 +64,10 @@ "Mohamedsabil83\\LaravelHijrian\\LaravelHijrianServiceProvider" ], "aliases": { - "Hijrian": "Mohamedsabil83\\LaravelHijrian\\LaravelHijrianFacade" + "Hijrian": "Mohamedsabil83\\LaravelHijrian\\Facades\\LaravelHijrian" } } - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..e69de29 diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..19a28c4 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 4 + paths: + - src + tmpDir: build/phpstan + checkOctaneCompatibility: true + checkModelProperties: true + checkMissingIterableValueType: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 22fe879..2aa9b91 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,29 +1,39 @@ - + - + tests - - - src/ - - + + + ./src + + + + + + + - - - - - + diff --git a/src/HijrianTrait.php b/src/Concerns/InteractsWithDates.php similarity index 98% rename from src/HijrianTrait.php rename to src/Concerns/InteractsWithDates.php index b3282a4..e12e02e 100644 --- a/src/HijrianTrait.php +++ b/src/Concerns/InteractsWithDates.php @@ -1,8 +1,8 @@ $mcjdn) { break; } @@ -159,11 +160,12 @@ private static function gth($year, $month, $day) } /** - * Convert Hijri to Gregorian + * Convert Hijri to Gregorian. * * @param int $year * @param int $month * @param int $day + * * @return \Carbon\Carbon */ private static function htg($year, $month, $day) @@ -182,9 +184,10 @@ private static function htg($year, $month, $day) } /** - * Convert Julian to Gregorian + * Convert Julian to Gregorian. * * @param int $date + * * @return \Carbon\Carbon * @source http://keith-wood.name/calendars.html */ diff --git a/src/Facades/LaravelHijrian.php b/src/Facades/LaravelHijrian.php new file mode 100644 index 0000000..61edc17 --- /dev/null +++ b/src/Facades/LaravelHijrian.php @@ -0,0 +1,17 @@ +parse($date)->format('Y-m-d')); - return self::gth(+$year, +$month, +$day); + + return self::gth((int) $year, (int) $month, (int) $day); } /** - * Return Gregorian date + * Return Gregorian date. * * @param string|null $date + * * @return \Carbon\Carbon */ public static function gregory($date = null) @@ -40,6 +44,7 @@ public static function gregory($date = null) } [$year, $month, $day] = explode('-', self::$date->parse($date)->format('Y-m-d')); - return self::htg(+$year, +$month, +$day); + + return self::htg((int) $year, (int) $month, (int) $day); } } diff --git a/src/LaravelHijrianFacade.php b/src/LaravelHijrianFacade.php deleted file mode 100644 index 8a39452..0000000 --- a/src/LaravelHijrianFacade.php +++ /dev/null @@ -1,18 +0,0 @@ -app->singleton(LaravelHijrian::class, function () { - return new LaravelHijrian; - }); - - $this->app->alias(LaravelHijrian::class, 'hijrian'); + $package + ->name('laravel-hijrian') + ; } } diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..50c34b4 --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,5 @@ +in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php index 369c065..5588b67 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,33 +2,15 @@ namespace Mohamedsabil83\LaravelHijrian\Tests; -use Orchestra\Testbench\TestCase as OrchestraTestCase; -use Mohamedsabil83\LaravelHijrian\LaravelHijrianFacade; +use Orchestra\Testbench\TestCase as Orchestra; use Mohamedsabil83\LaravelHijrian\LaravelHijrianServiceProvider; -abstract class TestCase extends OrchestraTestCase +class TestCase extends Orchestra { - /** - * Load package service provider - * - * @param \Illuminate\Foundation\Application $app - * @return LaravelHijrianServiceProvider - */ protected function getPackageProviders($app) - { - return [LaravelHijrianServiceProvider::class]; - } - - /** - * Load package alias - * - * @param \Illuminate\Foundation\Application $app - * @return array - */ - protected function getPackageAliases($app) { return [ - 'Hijrian' => LaravelHijrianFacade::class, + LaravelHijrianServiceProvider::class, ]; } } From 5f64cf6f9a39eff90e2d968060a2df80991ed818 Mon Sep 17 00:00:00 2001 From: MohamedSabil83 Date: Thu, 23 Dec 2021 04:30:38 +0300 Subject: [PATCH 2/4] Update tests to match pestphp --- tests/DateTest.php | 73 +++++++++++----------------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/tests/DateTest.php b/tests/DateTest.php index d9f65d1..4685416 100644 --- a/tests/DateTest.php +++ b/tests/DateTest.php @@ -1,64 +1,25 @@ hijri = '1440-12-08'; - $this->gregory = '2019-08-09'; - } +beforeEach(function () { + $this->gregory = '2019-08-09'; + $this->hijri = '1440-12-08'; +}); - /** - * @test Convert Gregory To Hijri. - * - * @return void - */ - public function convert_gregory_to_hijri() - { - $hijri = Hijrian::hijri($this->gregory); - $this->assertSame($this->hijri, $hijri->format('Y-m-d')); - } +it('Convert Gregory To Hijri', function () { + expect(LaravelHijrian::hijri($this->gregory)->format('Y-m-d'))->toEqual($this->hijri); +}); - /** - * @test Convert Hijri To Gregory. - * - * @return void - */ - public function convert_hijri_to_gregory() - { - $gregory = Hijrian::gregory($this->hijri); - $this->assertSame($this->gregory, $gregory->format('Y-m-d')); - } +it('Convert Hijri To Gregory', function () { + expect(LaravelHijrian::gregory($this->hijri)->format('Y-m-d'))->toEqual($this->gregory); +}); - /** - * @test Get Gregory date. - * - * @return void - */ - public function get_grogory_date() - { - $gregory = Hijrian::gregory(); - $this->assertInstanceOf(Carbon::class, $gregory); - } +it('Return A Grogory Date', function () { + expect(LaravelHijrian::gregory())->toBeInstanceOf(Carbon::class); +}); - /** - * @test Get Hijri date. - * - * @return void - */ - public function get_hijri_date() - { - $hijri = Hijrian::hijri(); - $this->assertInstanceOf(Carbon::class, $hijri); - } -} +it('Return A Hijri Date', function () { + expect(LaravelHijrian::hijri())->toBeInstanceOf(Carbon::class); +}); From 77eb096256efa3f695f843ce7bbc123cc1d5cabf Mon Sep 17 00:00:00 2001 From: MohamedSabil83 Date: Thu, 23 Dec 2021 04:45:04 +0300 Subject: [PATCH 3/4] Update README --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7127c4a..341d97b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -# Laravel Hijrian +# Hijri-Gregorian date converter for Laravel + +MohamedSabil83 [![Latest Version on Packagist](https://img.shields.io/packagist/v/mohamedsabil83/laravel-hijrian.svg?style=flat-square)](https://packagist.org/packages/mohamedsabil83/laravel-hijrian) -[![Build Status](https://img.shields.io/travis/mohamedsabil83/laravel-hijrian/master.svg?style=flat-square)](https://travis-ci.org/mohamedsabil83/laravel-hijrian) -[![Quality Score](https://img.shields.io/scrutinizer/g/mohamedsabil83/laravel-hijrian.svg?style=flat-square)](https://scrutinizer-ci.com/g/mohamedsabil83/laravel-hijrian) +[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/mohamedsabil83/laravel-hijrian/run-tests?label=tests)](https://github.com/mohamedsabil83/laravel-hijrian/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/mohamedsabil83/laravel-hijrian/Check%20&%20fix%20styling?label=code%20style)](https://github.com/mohamedsabil83/laravel-hijrian/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/mohamedsabil83/laravel-hijrian.svg?style=flat-square)](https://packagist.org/packages/mohamedsabil83/laravel-hijrian) This is a Hijri-Gregory date converter for Laravel 5.8+. It's return a date instance of **carbon**, so, you can make any process related to it. @@ -17,7 +19,7 @@ composer require mohamedsabil83/laravel-hijrian ## Usage -> Don't forget to add **`use Hijrian;`** at the top of your file. +Don't forget to add **`use Hijrian;`** at the top of your file. ### Get Hijri date @@ -43,27 +45,27 @@ Hijrian::hijri($gregory_date) Hijrian::gregory($hijri_date) ``` -### Testing +## Testing ```bash composer test ``` -### Changelog +## Changelog -Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing -Please see [CONTRIBUTING](CONTRIBUTING.md) for details. +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. -### Security +## Security Vulnerabilities -If you discover any security related issues, please email me@mohamedsabil83.com instead of using the issue tracker. +Please review [our security policy](../../security/policy) on how to report security vulnerabilities. ## Credits -- [Mohamed Sabil](https://github.com/mohamedsabil83) +- [MohamedSabil83](https://github.com/mohamedsabil83) - [All Contributors](../../contributors) ## License From 10cdbbd32f89d6473b386c10d367b30d0e1252a8 Mon Sep 17 00:00:00 2001 From: mohamedsabil83 Date: Thu, 23 Dec 2021 01:47:04 +0000 Subject: [PATCH 4/4] Fix styling --- tests/TestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 5588b67..c773ee9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,8 +2,8 @@ namespace Mohamedsabil83\LaravelHijrian\Tests; -use Orchestra\Testbench\TestCase as Orchestra; use Mohamedsabil83\LaravelHijrian\LaravelHijrianServiceProvider; +use Orchestra\Testbench\TestCase as Orchestra; class TestCase extends Orchestra {