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 diff --git a/.scrutinizer.yml b/.scrutinizer.yml index fb474e7..4b1692f 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -22,7 +22,7 @@ checks: tools: external_code_coverage: timeout: 1800 - runs: 12 + runs: 8 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index 6e901fb..378d088 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,10 @@ language: php sudo: false php: - - 5.5.9 - - 5.5 - 5.6 - 7.0 + - 7.1 - nightly - - hhvm matrix: allow_failures: @@ -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 @@ -29,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 bbe8c86..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] @@ -22,6 +21,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 +37,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. @@ -68,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 @@ -83,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 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.*" } } ``` 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": { 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; }