From ae98266b1929ff9372140cfd99faa4ef7b04ad09 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 28 Aug 2016 19:21:56 +0100 Subject: [PATCH 1/5] Updating .gitattributes & .gitignore --- .gitattributes | 1 - .gitignore | 2 -- 2 files changed, 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3a3ac45..a1bf466 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,5 +5,4 @@ /.gitignore export-ignore /.scrutinizer.yml export-ignore /.travis.yml export-ignore -/CONTRIBUTING.md export-ignore /phpunit.xml export-ignore diff --git a/.gitignore b/.gitignore index 78ce2fd..8c59329 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/.idea/ -/_arcanedev/ /build/ /vendor/ /composer.phar From f4fdfb84dfa5228423575281d2d5d653b0b80978 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 28 Aug 2016 19:22:37 +0100 Subject: [PATCH 2/5] Dropping PHP versions less than 5.6 --- .scrutinizer.yml | 4 ++-- .travis.yml | 3 +-- composer.json | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index fb474e7..df78ab1 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,8 +21,8 @@ checks: tools: external_code_coverage: - timeout: 1800 - runs: 12 + timeout: 1200 + runs: 8 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index 6e901fb..00c394a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ language: php sudo: false php: - - 5.5.9 - - 5.5 - 5.6 - 7.0 - nightly @@ -18,6 +16,7 @@ env: - TESTBENCH_VERSION=3.0.* - TESTBENCH_VERSION=3.1.* - TESTBENCH_VERSION=3.2.* + - TESTBENCH_VERSION=3.3.* before_script: - travis_retry composer self-update diff --git a/composer.json b/composer.json index 4d53bd6..4bc70ed 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "type": "library", "license": "MIT", "require": { - "php" : ">=5.5.9", + "php" : ">=5.6", "arcanedev/support": "~3.6" }, "require-dev": { From 13e52a51f07c45c801c1e1904e912a82b466af83 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 28 Aug 2016 19:32:07 +0100 Subject: [PATCH 3/5] Refactoring and Updating doc comments --- src/Localization.php | 63 ++++++++++++------------------------------- src/Utilities/Url.php | 4 +-- 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/src/Localization.php b/src/Localization.php index c1cfc12..5b22d78 100644 --- a/src/Localization.php +++ b/src/Localization.php @@ -3,7 +3,6 @@ use Arcanedev\Localization\Contracts\LocalesManagerInterface; use Arcanedev\Localization\Contracts\LocalizationInterface; use Arcanedev\Localization\Contracts\RouteTranslatorInterface; -use Arcanedev\Localization\Exceptions\UndefinedSupportedLocalesException; use Arcanedev\Localization\Exceptions\UnsupportedLocaleException; use Arcanedev\Localization\Utilities\Url; use Illuminate\Foundation\Application; @@ -22,30 +21,30 @@ class Localization implements LocalizationInterface | ------------------------------------------------------------------------------------------------ */ /** - * Laravel application instance. + * Base url. * - * @var Application + * @var string */ - private $app; + protected $baseUrl; /** - * Base url. + * Laravel application instance. * - * @var string + * @var \Illuminate\Foundation\Application */ - protected $baseUrl; + private $app; /** * The RouteTranslator instance. * - * @var RouteTranslatorInterface + * @var \Arcanedev\Localization\Contracts\RouteTranslatorInterface */ protected $routeTranslator; /** * The LocalesManager instance. * - * @var LocalesManagerInterface + * @var \Arcanedev\Localization\Contracts\LocalesManagerInterface */ private $localesManager; @@ -56,12 +55,9 @@ class Localization implements LocalizationInterface /** * Creates new instance. * - * @param Application $app - * @param RouteTranslatorInterface $routeTranslator - * @param LocalesManagerInterface $localesManager - * - * @throws UndefinedSupportedLocalesException - * @throws UnsupportedLocaleException + * @param \Illuminate\Foundation\Application $app + * @param \Arcanedev\Localization\Contracts\RouteTranslatorInterface $routeTranslator + * @param \Arcanedev\Localization\Contracts\LocalesManagerInterface $localesManager */ public function __construct( Application $app, @@ -84,7 +80,7 @@ public function __construct( /** * Get Request instance. * - * @return Request + * @return \Illuminate\Http\Request */ private function request() { @@ -105,8 +101,6 @@ public function getDefaultLocale() * Return an array of all supported Locales. * * @return \Arcanedev\Localization\Entities\LocaleCollection - * - * @throws UndefinedSupportedLocalesException */ public function getSupportedLocales() { @@ -131,8 +125,6 @@ public function setSupportedLocales(array $supportedLocales) * Get supported locales keys. * * @return array - * - * @throws UndefinedSupportedLocalesException */ public function getSupportedLocalesKeys() { @@ -240,9 +232,7 @@ public function setLocale($locale = null) */ public function setBaseUrl($url) { - if (substr($url, -1) !== '/') { - $url .= '/'; - } + if (substr($url, -1) !== '/') $url .= '/'; $this->baseUrl = $url; @@ -271,8 +261,6 @@ public function transRoute($routeName) * @param string|null $url * @param string|null $locale * - * @throws UnsupportedLocaleException - * * @return string */ public function localizeURL($url = null, $locale = null) @@ -302,9 +290,6 @@ public function getNonLocalizedURL($url = null) * @param array $attributes * * @return string|false - * - * @throws UndefinedSupportedLocalesException - * @throws UnsupportedLocaleException */ public function getLocalizedURL($locale = null, $url = null, $attributes = []) { @@ -386,11 +371,7 @@ public function createUrlFromUri($uri) { $uri = ltrim($uri, '/'); - if (empty($this->baseUrl)) { - return app('url')->to($uri); - } - - return $this->baseUrl . $uri; + return empty($this->baseUrl) ? app('url')->to($uri) : $this->baseUrl.$uri; } /** @@ -417,9 +398,6 @@ public function localesNavbar() * @param string $locale * * @return string|false - * - * @throws UndefinedSupportedLocalesException - * @throws UnsupportedLocaleException */ private function findTranslatedRouteByUrl($url, $attributes, $locale) { @@ -445,9 +423,6 @@ private function findTranslatedRouteByUrl($url, $attributes, $locale) * @param array $attributes * * @return string|false - * - * @throws UndefinedSupportedLocalesException - * @throws UnsupportedLocaleException */ public function getUrlFromRouteName($locale, $transKey, $attributes = []) { @@ -470,7 +445,7 @@ public function getUrlFromRouteName($locale, $transKey, $attributes = []) /** * Set route name from request. * - * @param Request $request + * @param \Illuminate\Http\Request $request */ public function setRouteNameFromRequest(Request $request) { @@ -500,15 +475,11 @@ public function isDefaultLocaleHiddenInUrl() * * @param string|bool $locale * - * @throws UndefinedSupportedLocalesException - * * @return bool */ public function isLocaleSupported($locale) { - return ( - $locale !== false && ! $this->localesManager->isSupportedLocale($locale) - ) ? false : true; + return ! ($locale !== false && ! $this->localesManager->isSupportedLocale($locale)); } /** @@ -516,7 +487,7 @@ public function isLocaleSupported($locale) * * @param string $locale * - * @throws UnsupportedLocaleException + * @throws \Arcanedev\Localization\Exceptions\UnsupportedLocaleException */ private function isLocaleSupportedOrFail($locale) { diff --git a/src/Utilities/Url.php b/src/Utilities/Url.php index 15069fd..93933f3 100644 --- a/src/Utilities/Url.php +++ b/src/Utilities/Url.php @@ -150,9 +150,7 @@ private static function hasAttributesFromUriPath($url, $path, &$attributes) } } - if (isset($url[$i + 1])) { - $match = false; - } + if (isset($url[$i + 1])) $match = false; return $match; } From 3139c9b6a4e874271ee8fcc5298a9f305a61c1b8 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 28 Aug 2016 19:36:52 +0100 Subject: [PATCH 4/5] Updating README.md and the docs --- README.md | 9 +-------- _docs/0-Home.md | 1 + _docs/1-Requirements.md | 2 +- _docs/2-Installation-and-Setup.md | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bbe8c86..238777e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Localization/ ### Features * Easy setup & configuration. + * Laravel `5.0 | 5.1 | 5.2 | 5.3` are supported. * SEO-Friendly (Search engine optimization). * New extended Router to manage your localized routes. * Locales selector menu (Publishable & Customizable). @@ -37,17 +38,9 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Localization/ 5. [Extras](_docs/5-Extras.md) 6. [FAQ](_docs/6-FAQ.md) -### DONE - - - [x] Laravel 5.2 supported. - - [x] Laravel 5.1 supported. - - [x] Laravel 5.0 supported. - - [x] Adding language selector view. - ### TODOS - [ ] 100% Code coverage + Maximum code quality. - - [ ] Laravel 5.3 support. - [ ] Complete the documentation. - [ ] Adding more regionals for locales. diff --git a/_docs/0-Home.md b/_docs/0-Home.md index acb6bff..339aeab 100644 --- a/_docs/0-Home.md +++ b/_docs/0-Home.md @@ -7,6 +7,7 @@ Feel free to check out the [Releases](https://github.com/ARCANEDEV/Localization/ ### Features * Easy setup & configuration. + * Laravel `5.0 | 5.1 | 5.2 | 5.3` are supported. * SEO-Friendly (Search engine optimization). * New extended Router to manage your localized routes. * Locales selector menu (Publishable & Customizable). diff --git a/_docs/1-Requirements.md b/_docs/1-Requirements.md index 7343ba4..298adf5 100644 --- a/_docs/1-Requirements.md +++ b/_docs/1-Requirements.md @@ -4,7 +4,7 @@ The Localization package has a few system requirements: - - PHP >= 5.5.9 + - PHP >= 5.6 ##### Optional diff --git a/_docs/2-Installation-and-Setup.md b/_docs/2-Installation-and-Setup.md index 9a6cd3c..94198fc 100644 --- a/_docs/2-Installation-and-Setup.md +++ b/_docs/2-Installation-and-Setup.md @@ -9,7 +9,7 @@ Or by adding the package to your `composer.json`. ```json { "require": { - "arcanedev/localization": "0.7.*" + "arcanedev/localization": "0.8.*" } } ``` From 5db93d1ab0bc6f98849d5c2b52b35d1480d44c79 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Sun, 28 Aug 2016 19:52:57 +0100 Subject: [PATCH 5/5] Dropping the HHVM Support --- .scrutinizer.yml | 2 +- .travis.yml | 6 +++--- README.md | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index df78ab1..4b1692f 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,7 +21,7 @@ checks: tools: external_code_coverage: - timeout: 1200 + timeout: 1800 runs: 8 php_code_sniffer: enabled: true diff --git a/.travis.yml b/.travis.yml index 00c394a..378d088 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ sudo: false php: - 5.6 - 7.0 + - 7.1 - nightly - - hhvm matrix: allow_failures: @@ -28,5 +28,5 @@ script: - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover after_script: - - if [ "$TRAVIS_PHP_VERSION" != "nightly" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" != "nightly" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi + - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi + - if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/README.md b/README.md index 238777e..6b924c5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Localization [![Packagist License][badge_license]](LICENSE.md) [![For Laravel 5][badge_laravel]][link-github-repo] [![Travis Status][badge_build]][link-travis] -[![HHVM Status][badge_hhvm]][link-hhvm] [![Coverage Status][badge_coverage]][link-scrutinizer] [![Scrutinizer Code Quality][badge_quality]][link-scrutinizer] [![SensioLabs Insight][badge_insight]][link-insight] @@ -61,7 +60,6 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [badge_license]: http://img.shields.io/packagist/l/arcanedev/localization.svg?style=flat-square [badge_laravel]: https://img.shields.io/badge/For-Laravel%205-orange.svg?style=flat-square [badge_build]: http://img.shields.io/travis/ARCANEDEV/Localization.svg?style=flat-square -[badge_hhvm]: https://img.shields.io/hhvm/arcanedev/localization.svg?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Localization.svg?style=flat-square [badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/Localization.svg?style=flat-square [badge_insight]: https://img.shields.io/sensiolabs/i/30a231b2-295e-466a-8733-fe95cf2bc48d.svg?style=flat-square @@ -76,6 +74,5 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [link-contributors]: https://github.com/ARCANEDEV/Localization/graphs/contributors [link-packagist]: https://packagist.org/packages/arcanedev/localization [link-travis]: https://travis-ci.org/ARCANEDEV/Localization -[link-hhvm]: http://hhvm.h4cc.de/package/arcanedev/localization [link-scrutinizer]: https://scrutinizer-ci.com/g/ARCANEDEV/Localization/?branch=master [link-insight]: https://insight.sensiolabs.com/projects/30a231b2-295e-466a-8733-fe95cf2bc48d