diff --git a/.gitattributes b/.gitattributes index 7ccb1f3..22f739a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,5 @@ .gitattributes export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore -.travis.yml export-ignore phpunit.xml.dist export-ignore CONTRIBUTING.md export-ignore diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..10b997e --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,46 @@ +name: run-tests + +on: [push] + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php: [7.2, 7.3, 7.4] + laravel: [6.*] + dependency-version: [prefer-lowest, prefer-stable] + + name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php }} + extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv + coverage: xdebug + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: | + mkdir -p build/logs + vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + + - name: Scrutinizer CI + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3d5c231..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - nightly - -matrix: - allow_failures: - - php: nightly - -before_script: - - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction --dev - -script: - - composer validate - - mkdir -p build/logs - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - 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 ca49ec5..d62cc39 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SEO Helper [![Packagist License][badge_license]](LICENSE.md) [![For PHP][badge_php]][link-github-repo] -[![Travis Status][badge_build]][link-travis] +[![Github Workflow Status][badge_build]][link-github-status] [![Coverage Status][badge_coverage]][link-scrutinizer] [![Scrutinizer Code Quality][badge_quality]][link-scrutinizer] [![SensioLabs Insight][badge_insight]][link-insight] @@ -51,7 +51,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [badge_php]: https://img.shields.io/badge/PHP-Framework%20agnostic-4F5B93.svg?style=flat-square [badge_license]: https://img.shields.io/packagist/l/arcanedev/seo-helper.svg?style=flat-square -[badge_build]: https://img.shields.io/travis/ARCANEDEV/SEO-Helper.svg?style=flat-square +[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/SEO-Helper/run-tests?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/SEO-Helper.svg?style=flat-square [badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/SEO-Helper.svg?style=flat-square [badge_insight]: https://img.shields.io/sensiolabs/i/73e1a779-7ca7-4a75-b6d3-452d7852187e.svg?style=flat-square @@ -62,6 +62,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. [link-author]: https://github.com/arcanedev-maroc [link-github-repo]: https://github.com/ARCANEDEV/SEO-Helper +[link-github-status]: https://github.com/ARCANEDEV/SEO-Helper/actions [link-github-issues]: https://github.com/ARCANEDEV/SEO-Helper/issues [link-contributors]: https://github.com/ARCANEDEV/SEO-Helper/graphs/contributors [link-packagist]: https://packagist.org/packages/arcanedev/seo-helper diff --git a/composer.json b/composer.json index cc0a36d..596b8ee 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=7.2.0", "arcanedev/php-html": "^3.0", - "arcanedev/support": "^5.0" + "arcanedev/support": "^5.1" }, "require-dev": { "ext-dom": "*", diff --git a/src/Bases/MetaCollection.php b/src/Bases/MetaCollection.php index b557437..a033001 100644 --- a/src/Bases/MetaCollection.php +++ b/src/Bases/MetaCollection.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Bases; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Bases; use Arcanedev\SeoHelper\Contracts\Entities\MetaCollection as MetaCollectionContract; use Arcanedev\SeoHelper\Contracts\Helpers\Meta as MetaContract; @@ -57,7 +61,7 @@ abstract class MetaCollection extends Collection implements MetaCollectionContra * * @param string $prefix * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ public function setPrefix($prefix) { @@ -67,7 +71,7 @@ public function setPrefix($prefix) } /* ----------------------------------------------------------------- - | Main Functions + | Main Methods | ----------------------------------------------------------------- */ @@ -76,7 +80,7 @@ public function setPrefix($prefix) * * @param array $metas * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ public function addMany(array $metas) { @@ -93,7 +97,7 @@ public function addMany(array $metas) * @param string $name * @param string|array $content * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ public function addOne($name, $content) { @@ -109,7 +113,7 @@ public function addOne($name, $content) * @param string $name * @param string|array $content * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ protected function addMeta($name, $content) { @@ -123,7 +127,7 @@ protected function addMeta($name, $content) * * @param array|string $names * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ public function remove($names) { @@ -149,7 +153,7 @@ public function render() /** * Reset the collection. * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ public function reset() { @@ -195,7 +199,7 @@ protected function isIgnored($name) * * @param string|array $keys * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ public function forget($keys) { @@ -209,7 +213,7 @@ public function forget($keys) /** * Refresh meta collection items. * - * @return \Arcanedev\SeoHelper\Bases\MetaCollection + * @return $this */ private function refresh() { diff --git a/src/Contracts/Entities/Analytics.php b/src/Contracts/Entities/Analytics.php index 4d2925e..c2a7e4a 100644 --- a/src/Contracts/Entities/Analytics.php +++ b/src/Contracts/Entities/Analytics.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,6 +18,7 @@ interface Analytics extends Renderable | Getters & Setters | ----------------------------------------------------------------- */ + /** * Set Google Analytics code. * diff --git a/src/Contracts/Entities/Description.php b/src/Contracts/Entities/Description.php index c18ee3d..7136913 100644 --- a/src/Contracts/Entities/Description.php +++ b/src/Contracts/Entities/Description.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,6 +18,7 @@ interface Description extends Renderable | Getters & Setters | ----------------------------------------------------------------- */ + /** * Get raw description content. * @@ -33,7 +38,7 @@ public function get(); * * @param string $content * - * @return self + * @return $this */ public function set($content); @@ -49,7 +54,7 @@ public function getMax(); * * @param int $max * - * @return self + * @return $this */ public function setMax($max); @@ -57,13 +62,14 @@ public function setMax($max); | Main Methods | ----------------------------------------------------------------- */ + /** * Make a description instance. * * @param string $content * @param int $max * - * @return self + * @return $this */ public static function make($content, $max = 155); } diff --git a/src/Contracts/Entities/Keywords.php b/src/Contracts/Entities/Keywords.php index fdfdd53..6cfb607 100644 --- a/src/Contracts/Entities/Keywords.php +++ b/src/Contracts/Entities/Keywords.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,6 +18,7 @@ interface Keywords extends Renderable | Getters & Setters | ----------------------------------------------------------------- */ + /** * Get content. * @@ -26,20 +31,21 @@ public function getContent(); * * @param array|string $content * - * @return self + * @return $this */ public function set($content); /* ----------------------------------------------------------------- - | Main Functions + | Main Methods | ----------------------------------------------------------------- */ + /** * Make Keywords instance. * * @param array|string $keywords * - * @return self + * @return $this */ public static function make($keywords); @@ -48,7 +54,7 @@ public static function make($keywords); * * @param string $keyword * - * @return self + * @return $this */ public function add($keyword); @@ -57,7 +63,7 @@ public function add($keyword); * * @param array $keywords * - * @return self + * @return $this */ public function addMany(array $keywords); } diff --git a/src/Contracts/Entities/MetaCollection.php b/src/Contracts/Entities/MetaCollection.php index c5f0279..347888f 100644 --- a/src/Contracts/Entities/MetaCollection.php +++ b/src/Contracts/Entities/MetaCollection.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -11,16 +15,17 @@ interface MetaCollection extends Renderable { /* ----------------------------------------------------------------- - | Main Functions + | Main Methods | ----------------------------------------------------------------- */ + /** * Add a meta to collection. * * @param string $name * @param string|array $content * - * @return self + * @return $this */ public function addOne($name, $content); @@ -29,7 +34,7 @@ public function addOne($name, $content); * * @param array $metas * - * @return self + * @return $this */ public function addMany(array $metas); @@ -38,7 +43,7 @@ public function addMany(array $metas); * * @param array|string $names * - * @return self + * @return $this */ public function remove($names); } diff --git a/src/Contracts/Entities/MiscTags.php b/src/Contracts/Entities/MiscTags.php index 8a6969c..aabbbb7 100644 --- a/src/Contracts/Entities/MiscTags.php +++ b/src/Contracts/Entities/MiscTags.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -27,7 +31,7 @@ public function getUrl(); * * @param string $url * - * @return self + * @return $this */ public function setUrl($url); @@ -48,7 +52,7 @@ public function all(); * * @param array $defaults * - * @return self + * @return $this */ public static function make(array $defaults = []); @@ -58,7 +62,7 @@ public static function make(array $defaults = []); * @param string $name * @param string $content * - * @return self + * @return $this */ public function add($name, $content); @@ -67,7 +71,7 @@ public function add($name, $content); * * @param array $metas * - * @return self + * @return $this */ public function addMany(array $metas); @@ -76,14 +80,14 @@ public function addMany(array $metas); * * @param array|string $names * - * @return self + * @return $this */ public function remove($names); /** * Reset the meta collection. * - * @return self + * @return $this */ public function reset(); } diff --git a/src/Contracts/Entities/OpenGraph.php b/src/Contracts/Entities/OpenGraph.php index 9bd1ea4..01de133 100644 --- a/src/Contracts/Entities/OpenGraph.php +++ b/src/Contracts/Entities/OpenGraph.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,12 +18,13 @@ interface OpenGraph extends Renderable | Getters & Setters | ----------------------------------------------------------------- */ + /** * Set the open graph prefix. * * @param string $prefix * - * @return self + * @return $this */ public function setPrefix($prefix); @@ -28,7 +33,7 @@ public function setPrefix($prefix); * * @param string $type * - * @return self + * @return $this */ public function setType($type); @@ -37,7 +42,7 @@ public function setType($type); * * @param string $title * - * @return self + * @return $this */ public function setTitle($title); @@ -46,7 +51,7 @@ public function setTitle($title); * * @param string $description * - * @return self + * @return $this */ public function setDescription($description); @@ -55,7 +60,7 @@ public function setDescription($description); * * @param string $url * - * @return self + * @return $this */ public function setUrl($url); @@ -64,7 +69,7 @@ public function setUrl($url); * * @param string $image * - * @return self + * @return $this */ public function setImage($image); @@ -73,7 +78,7 @@ public function setImage($image); * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName); @@ -100,7 +105,7 @@ public function setAlternativeLocales(array $locales); * * @param array $properties * - * @return self + * @return $this */ public function addProperties(array $properties); @@ -110,7 +115,7 @@ public function addProperties(array $properties); * @param string $property * @param string|array $content * - * @return self + * @return $this */ public function addProperty($property, $content); } diff --git a/src/Contracts/Entities/Title.php b/src/Contracts/Entities/Title.php index 430d01e..b474c0d 100644 --- a/src/Contracts/Entities/Title.php +++ b/src/Contracts/Entities/Title.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,6 +18,7 @@ interface Title extends Renderable | Getters & Setters | ----------------------------------------------------------------- */ + /** * Get title only (without site name or separator). * @@ -26,7 +31,7 @@ public function getTitleOnly(); * * @param string $title * - * @return self + * @return $this */ public function set($title); @@ -42,21 +47,21 @@ public function getSiteName(); * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName); /** * Hide the site name. * - * @return self + * @return $this */ public function hideSiteName(); /** * Show the site name. * - * @return self + * @return $this */ public function showSiteName(); @@ -65,7 +70,7 @@ public function showSiteName(); * * @param bool $visible * - * @return self + * @return $this */ public function setSiteNameVisibility($visible); @@ -81,21 +86,21 @@ public function getSeparator(); * * @param string $separator * - * @return self + * @return $this */ public function setSeparator($separator); /** * Set title first. * - * @return self + * @return $this */ public function setFirst(); /** * Set title last. * - * @return self + * @return $this */ public function setLast(); @@ -107,7 +112,7 @@ public function setLast(); public function isTitleFirst(); /** - * Get title max lenght. + * Get title max length. * * @return int */ @@ -118,7 +123,7 @@ public function getMax(); * * @param int $max * - * @return self + * @return $this */ public function setMax($max); @@ -126,6 +131,7 @@ public function setMax($max); | Main Methods | ----------------------------------------------------------------- */ + /** * Make a Title instance. * @@ -133,7 +139,7 @@ public function setMax($max); * @param string $siteName * @param string $separator * - * @return self + * @return $this */ public static function make($title, $siteName = '', $separator = '-'); } diff --git a/src/Contracts/Entities/TwitterCard.php b/src/Contracts/Entities/TwitterCard.php index e83b9e9..d98231f 100644 --- a/src/Contracts/Entities/TwitterCard.php +++ b/src/Contracts/Entities/TwitterCard.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,6 +18,7 @@ interface TwitterCard extends Renderable | Constants | ----------------------------------------------------------------- */ + const TYPE_APP = 'app'; const TYPE_GALLERY = 'gallery'; const TYPE_PHOTO = 'photo'; @@ -26,12 +31,13 @@ interface TwitterCard extends Renderable | Getters & Setters | ----------------------------------------------------------------- */ + /** * Set the card type. * * @param string $type * - * @return self + * @return $this */ public function setType($type); @@ -40,7 +46,7 @@ public function setType($type); * * @param string $site * - * @return self + * @return $this */ public function setSite($site); @@ -49,7 +55,7 @@ public function setSite($site); * * @param string $title * - * @return self + * @return $this */ public function setTitle($title); @@ -58,7 +64,7 @@ public function setTitle($title); * * @param string $description * - * @return self + * @return $this */ public function setDescription($description); @@ -67,7 +73,7 @@ public function setDescription($description); * * @param string $url * - * @return self + * @return $this */ public function addImage($url); @@ -76,7 +82,7 @@ public function addImage($url); * * @param array $metas * - * @return self + * @return $this */ public function addMetas(array $metas); @@ -86,7 +92,7 @@ public function addMetas(array $metas); * @param string $name * @param string|array $content * - * @return self + * @return $this */ public function addMeta($name, $content); @@ -101,10 +107,11 @@ public function types(); | Main Methods | ----------------------------------------------------------------- */ + /** * Reset the card. * - * @return self + * @return $this */ public function reset(); } diff --git a/src/Contracts/Entities/Webmasters.php b/src/Contracts/Entities/Webmasters.php index c235b84..cf5f71f 100644 --- a/src/Contracts/Entities/Webmasters.php +++ b/src/Contracts/Entities/Webmasters.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Entities; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -32,7 +36,7 @@ public function all(); * * @param array $webmasters * - * @return self + * @return $this */ public static function make(array $webmasters = []); @@ -42,14 +46,14 @@ public static function make(array $webmasters = []); * @param string $webmaster * @param string $content * - * @return self + * @return $this */ public function add($webmaster, $content); /** * Reset the webmaster collection. * - * @return self + * @return $this */ public function reset(); } diff --git a/src/Contracts/Helpers/Meta.php b/src/Contracts/Helpers/Meta.php index aaddf87..cc9ba55 100644 --- a/src/Contracts/Helpers/Meta.php +++ b/src/Contracts/Helpers/Meta.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts\Helpers; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts\Helpers; use Arcanedev\SeoHelper\Contracts\Renderable; @@ -14,6 +18,7 @@ interface Meta extends Renderable | Getters and Setters | ----------------------------------------------------------------- */ + /** * Get the meta name. * @@ -26,7 +31,7 @@ public function key(); * * @param string $prefix * - * @return self + * @return $this */ public function setPrefix($prefix); @@ -35,7 +40,7 @@ public function setPrefix($prefix); * * @param string $nameProperty * - * @return self + * @return $this */ public function setNameProperty($nameProperty); @@ -43,6 +48,7 @@ public function setNameProperty($nameProperty); | Main Methods | ----------------------------------------------------------------- */ + /** * Make Meta instance. * @@ -51,7 +57,7 @@ public function setNameProperty($nameProperty); * @param string $propertyName * @param string $prefix * - * @return self + * @return $this */ public static function make($name, $content, $propertyName = 'name', $prefix = ''); diff --git a/src/Contracts/Renderable.php b/src/Contracts/Renderable.php index 93f3935..8dcc71b 100644 --- a/src/Contracts/Renderable.php +++ b/src/Contracts/Renderable.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts; /** * Interface Renderable diff --git a/src/Contracts/SeoHelper.php b/src/Contracts/SeoHelper.php index d78b82b..1c92725 100644 --- a/src/Contracts/SeoHelper.php +++ b/src/Contracts/SeoHelper.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts; /** * Interface SeoHelper @@ -24,7 +28,7 @@ public function meta(); * * @param \Arcanedev\SeoHelper\Contracts\SeoMeta $seoMeta * - * @return self + * @return $this */ public function setSeoMeta(SeoMeta $seoMeta); @@ -49,7 +53,7 @@ public function og(); * * @param \Arcanedev\SeoHelper\Contracts\SeoOpenGraph $seoOpenGraph * - * @return self + * @return $this */ public function setSeoOpenGraph(SeoOpenGraph $seoOpenGraph); @@ -65,7 +69,7 @@ public function twitter(); * * @param \Arcanedev\SeoHelper\Contracts\SeoTwitter $seoTwitter * - * @return self + * @return $this */ public function setSeoTwitter(SeoTwitter $seoTwitter); @@ -76,7 +80,7 @@ public function setSeoTwitter(SeoTwitter $seoTwitter); * @param string|null $siteName * @param string|null $separator * - * @return self + * @return $this */ public function setTitle($title, $siteName = null, $separator = null); @@ -85,21 +89,21 @@ public function setTitle($title, $siteName = null, $separator = null); * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName); /** * Hide the site name. * - * @return self + * @return $this */ public function hideSiteName(); /** * Show the site name. * - * @return self + * @return $this */ public function showSiteName(); @@ -108,7 +112,7 @@ public function showSiteName(); * * @param string $description * - * @return self + * @return $this */ public function setDescription($description); @@ -117,7 +121,7 @@ public function setDescription($description); * * @param array|string $keywords * - * @return self + * @return $this */ public function setKeywords($keywords); @@ -153,28 +157,28 @@ public function renderHtml(); /** * Enable the OpenGraph. * - * @return self + * @return $this */ public function enableOpenGraph(); /** * Disable the OpenGraph. * - * @return self + * @return $this */ public function disableOpenGraph(); /** * Enable the Twitter Card. * - * @return self + * @return $this */ public function enableTwitter(); /** * Disable the Twitter Card. * - * @return self + * @return $this */ public function disableTwitter(); } diff --git a/src/Contracts/SeoMeta.php b/src/Contracts/SeoMeta.php index ce2c66b..bfdaaff 100644 --- a/src/Contracts/SeoMeta.php +++ b/src/Contracts/SeoMeta.php @@ -1,11 +1,17 @@ -<?php namespace Arcanedev\SeoHelper\Contracts; +<?php -use Arcanedev\SeoHelper\Contracts\Entities\Analytics as AnalyticsContract; -use Arcanedev\SeoHelper\Contracts\Entities\Description as DescriptionContract; -use Arcanedev\SeoHelper\Contracts\Entities\Keywords as KeywordsContract; -use Arcanedev\SeoHelper\Contracts\Entities\MiscTags as MiscTagsContract; -use Arcanedev\SeoHelper\Contracts\Entities\Title as TitleContract; -use Arcanedev\SeoHelper\Contracts\Entities\Webmasters as WebmastersContract; +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts; + +use Arcanedev\SeoHelper\Contracts\Entities\{ + Analytics as AnalyticsContract, + Description as DescriptionContract, + Keywords as KeywordsContract, + MiscTags as MiscTagsContract, + Title as TitleContract, + Webmasters as WebmastersContract +}; /** * Interface SeoMeta @@ -24,7 +30,7 @@ interface SeoMeta extends Renderable * * @param \Arcanedev\SeoHelper\Contracts\Entities\Title $title * - * @return self + * @return $this */ public function title(TitleContract $title); @@ -40,7 +46,7 @@ public function getTitleEntity(); * * @param \Arcanedev\SeoHelper\Contracts\Entities\Description $description * - * @return self + * @return $this */ public function description(DescriptionContract $description); @@ -56,7 +62,7 @@ public function getDescriptionEntity(); * * @param \Arcanedev\SeoHelper\Contracts\Entities\Keywords $keywords * - * @return self + * @return $this */ public function keywords(KeywordsContract $keywords); @@ -72,7 +78,7 @@ public function getKeywordsEntity(); * * @param \Arcanedev\SeoHelper\Contracts\Entities\MiscTags $misc * - * @return self + * @return $this */ public function misc(MiscTagsContract $misc); @@ -88,7 +94,7 @@ public function getMiscEntity(); * * @param \Arcanedev\SeoHelper\Contracts\Entities\Webmasters $webmasters * - * @return self + * @return $this */ public function webmasters(WebmastersContract $webmasters); @@ -122,7 +128,7 @@ public function getAnalyticsEntity(); * @param string $siteName * @param string $separator * - * @return self + * @return $this */ public function setTitle($title, $siteName = null, $separator = null); @@ -131,21 +137,21 @@ public function setTitle($title, $siteName = null, $separator = null); * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName); /** * Hide site name. * - * @return self + * @return $this */ public function hideSiteName(); /** * Show site name. * - * @return self + * @return $this */ public function showSiteName(); @@ -154,7 +160,7 @@ public function showSiteName(); * * @param string $content * - * @return self + * @return $this */ public function setDescription($content); @@ -163,7 +169,7 @@ public function setDescription($content); * * @param array|string $content * - * @return self + * @return $this */ public function setKeywords($content); @@ -172,7 +178,7 @@ public function setKeywords($content); * * @param string $keyword * - * @return self + * @return $this */ public function addKeyword($keyword); @@ -181,7 +187,7 @@ public function addKeyword($keyword); * * @param array $keywords * - * @return self + * @return $this */ public function addKeywords(array $keywords); @@ -191,7 +197,7 @@ public function addKeywords(array $keywords); * @param string $webmaster * @param string $content * - * @return self + * @return $this */ public function addWebmaster($webmaster, $content); @@ -200,7 +206,7 @@ public function addWebmaster($webmaster, $content); * * @param string $url * - * @return self + * @return $this */ public function setUrl($url); @@ -209,7 +215,7 @@ public function setUrl($url); * * @param string $code * - * @return self + * @return $this */ public function setGoogleAnalytics($code); @@ -223,7 +229,7 @@ public function setGoogleAnalytics($code); * @param string $name * @param string $content * - * @return self + * @return $this */ public function addMeta($name, $content); @@ -232,7 +238,7 @@ public function addMeta($name, $content); * * @param array $metas * - * @return self + * @return $this */ public function addMetas(array $metas); @@ -241,21 +247,21 @@ public function addMetas(array $metas); * * @param string|array $names * - * @return self + * @return $this */ public function removeMeta($names); /** * Reset the meta collection except the description and keywords metas. * - * @return self + * @return $this */ public function resetMetas(); /** * Reset all webmaster tool site verifier metas. * - * @return self + * @return $this */ public function resetWebmasters(); } diff --git a/src/Contracts/SeoOpenGraph.php b/src/Contracts/SeoOpenGraph.php index 130d7e2..fbc0937 100644 --- a/src/Contracts/SeoOpenGraph.php +++ b/src/Contracts/SeoOpenGraph.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Contracts; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts; use Arcanedev\SeoHelper\Contracts\Entities\OpenGraph as OpenGraphContract; @@ -19,7 +23,7 @@ interface SeoOpenGraph extends Renderable * * @param \Arcanedev\SeoHelper\Contracts\Entities\OpenGraph $openGraph * - * @return self + * @return $this */ public function setOpenGraph(OpenGraphContract $openGraph); @@ -28,7 +32,7 @@ public function setOpenGraph(OpenGraphContract $openGraph); * * @param string $prefix * - * @return self + * @return $this */ public function setPrefix($prefix); @@ -37,7 +41,7 @@ public function setPrefix($prefix); * * @param string $type * - * @return self + * @return $this */ public function setType($type); @@ -46,7 +50,7 @@ public function setType($type); * * @param string $title * - * @return self + * @return $this */ public function setTitle($title); @@ -55,7 +59,7 @@ public function setTitle($title); * * @param string $description * - * @return self + * @return $this */ public function setDescription($description); @@ -64,7 +68,7 @@ public function setDescription($description); * * @param string $url * - * @return self + * @return $this */ public function setUrl($url); @@ -73,7 +77,7 @@ public function setUrl($url); * * @param string $image * - * @return self + * @return $this */ public function setImage($image); @@ -82,7 +86,7 @@ public function setImage($image); * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName); @@ -109,7 +113,7 @@ public function setAlternativeLocales(array $locales); * * @param array $properties * - * @return self + * @return $this */ public function addProperties(array $properties); @@ -119,7 +123,7 @@ public function addProperties(array $properties); * @param string $property * @param string $content * - * @return self + * @return $this */ public function addProperty($property, $content); @@ -130,14 +134,14 @@ public function addProperty($property, $content); /** * Enable the OpenGraph. * - * @return self + * @return $this */ public function enable(); /** * Disable the OpenGraph. * - * @return self + * @return $this */ public function disable(); diff --git a/src/Contracts/SeoTwitter.php b/src/Contracts/SeoTwitter.php index da8469c..c63c5cf 100644 --- a/src/Contracts/SeoTwitter.php +++ b/src/Contracts/SeoTwitter.php @@ -1,6 +1,10 @@ -<?php namespace Arcanedev\SeoHelper\Contracts; +<?php -use \Arcanedev\SeoHelper\Contracts\Entities\TwitterCard as CardContract; +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Contracts; + +use Arcanedev\SeoHelper\Contracts\Entities\TwitterCard as CardContract; /** * Interface SeoTwitter @@ -19,7 +23,7 @@ interface SeoTwitter extends Renderable * * @param \Arcanedev\SeoHelper\Contracts\Entities\TwitterCard $card * - * @return self + * @return $this */ public function setCard(CardContract $card); @@ -28,7 +32,7 @@ public function setCard(CardContract $card); * * @param string $type * - * @return self + * @return $this */ public function setType($type); @@ -37,7 +41,7 @@ public function setType($type); * * @param string $site * - * @return self + * @return $this */ public function setSite($site); @@ -46,7 +50,7 @@ public function setSite($site); * * @param string $title * - * @return self + * @return $this */ public function setTitle($title); @@ -55,7 +59,7 @@ public function setTitle($title); * * @param string $description * - * @return self + * @return $this */ public function setDescription($description); @@ -64,7 +68,7 @@ public function setDescription($description); * * @param string $url * - * @return self + * @return $this */ public function addImage($url); @@ -73,7 +77,7 @@ public function addImage($url); * * @param array $metas * - * @return self + * @return $this */ public function addMetas(array $metas); @@ -83,7 +87,7 @@ public function addMetas(array $metas); * @param string $name * @param string $content * - * @return self + * @return $this */ public function addMeta($name, $content); @@ -94,21 +98,21 @@ public function addMeta($name, $content); /** * Reset the twitter card. * - * @return self + * @return $this */ public function reset(); /** * Enable the Twitter Card. * - * @return self + * @return $this */ public function enable(); /** * Disable the Twitter Card. * - * @return self + * @return $this */ public function disable(); diff --git a/src/Entities/Analytics.php b/src/Entities/Analytics.php index 6c8fa83..ed0c78f 100644 --- a/src/Entities/Analytics.php +++ b/src/Entities/Analytics.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\SeoHelper\Contracts\Entities\Analytics as AnalyticsContract; use Arcanedev\Support\Traits\Configurable; @@ -57,7 +61,7 @@ public function __construct(array $configs = []) * * @param string $code * - * @return \Arcanedev\SeoHelper\Entities\Analytics + * @return $this */ public function setGoogle($code) { diff --git a/src/Entities/Description.php b/src/Entities/Description.php index 809f837..905006e 100644 --- a/src/Entities/Description.php +++ b/src/Entities/Description.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\Html\Elements\Meta; use Arcanedev\SeoHelper\Contracts\Entities\Description as DescriptionContract; @@ -94,7 +98,7 @@ public function get() * * @param string $content * - * @return self + * @return $this */ public function set($content) { @@ -118,7 +122,7 @@ public function getMax() * * @param int $max * - * @return self + * @return $this */ public function setMax($max) { @@ -140,7 +144,7 @@ public function setMax($max) * @param string $content * @param int $max * - * @return self + * @return $this */ public static function make($content, $max = 155) { diff --git a/src/Entities/Keywords.php b/src/Entities/Keywords.php index 040cb2c..d5aabd8 100644 --- a/src/Entities/Keywords.php +++ b/src/Entities/Keywords.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\Html\Elements\Meta; use Arcanedev\SeoHelper\Contracts\Entities\Keywords as KeywordsContract; @@ -84,19 +88,17 @@ public function get() * * @param array|string $content * - * @return self + * @return $this */ public function set($content) { - if (is_string($content)) + if (is_string($content)) { $content = explode(',', $content); - - if ( ! is_array($content)) - $content = (array) $content; + } $this->content = array_map(function ($keyword) { return $this->clean($keyword); - }, $content); + }, (array) $content); return $this; } @@ -111,7 +113,7 @@ public function set($content) * * @param array|string $keywords * - * @return self + * @return $this */ public static function make($keywords) { @@ -123,7 +125,7 @@ public static function make($keywords) * * @param string $keyword * - * @return self + * @return $this */ public function add($keyword) { @@ -137,7 +139,7 @@ public function add($keyword) * * @param array $keywords * - * @return self + * @return $this */ public function addMany(array $keywords) { diff --git a/src/Entities/MetaCollection.php b/src/Entities/MetaCollection.php index e706938..b3afb4c 100644 --- a/src/Entities/MetaCollection.php +++ b/src/Entities/MetaCollection.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\SeoHelper\Bases\MetaCollection as BaseMetaCollection; use Arcanedev\SeoHelper\Helpers\Meta; @@ -37,7 +41,7 @@ class MetaCollection extends BaseMetaCollection * @param string $name * @param string $content * - * @return \Arcanedev\SeoHelper\Entities\MetaCollection + * @return $this */ public function addOne($name, $content) { diff --git a/src/Entities/MiscTags.php b/src/Entities/MiscTags.php index 1d76b40..9397b13 100644 --- a/src/Entities/MiscTags.php +++ b/src/Entities/MiscTags.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\SeoHelper\Contracts\Entities\MiscTags as MiscTagsContract; use Arcanedev\Support\Traits\Configurable; @@ -85,7 +89,7 @@ public function getUrl() * * @param string $url * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ public function setUrl($url) { @@ -115,7 +119,7 @@ public function all() * * @param array $defaults * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ public static function make(array $defaults = []) { @@ -128,7 +132,7 @@ public static function make(array $defaults = []) * @param string $name * @param string $content * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ public function add($name, $content) { @@ -142,7 +146,7 @@ public function add($name, $content) * * @param array $metas * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ public function addMany(array $metas) { @@ -156,7 +160,7 @@ public function addMany(array $metas) * * @param array|string $names * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ public function remove($names) { @@ -168,7 +172,7 @@ public function remove($names) /** * Reset the meta collection. * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ public function reset() { @@ -240,7 +244,7 @@ private function isRobotsEnabled(): bool /** * Add the robots meta. * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ private function addRobotsMeta(): self { @@ -253,7 +257,7 @@ private function addRobotsMeta(): self /** * Add the canonical link. * - * @return \Arcanedev\SeoHelper\Entities\MiscTags + * @return $this */ private function addCanonical(): self { diff --git a/src/Entities/OpenGraph/Graph.php b/src/Entities/OpenGraph/Graph.php index 06bce1f..e16e70b 100644 --- a/src/Entities/OpenGraph/Graph.php +++ b/src/Entities/OpenGraph/Graph.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities\OpenGraph; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities\OpenGraph; use Arcanedev\SeoHelper\Contracts\Entities\OpenGraph as OpenGraphContract; use Arcanedev\Support\Traits\Configurable; @@ -71,7 +75,7 @@ private function init() * * @param string $prefix * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setPrefix($prefix) { @@ -85,7 +89,7 @@ public function setPrefix($prefix) * * @param string $type * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setType($type) { @@ -97,7 +101,7 @@ public function setType($type) * * @param string $title * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setTitle($title) { @@ -109,7 +113,7 @@ public function setTitle($title) * * @param string $description * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setDescription($description) { @@ -121,7 +125,7 @@ public function setDescription($description) * * @param string $url * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setUrl($url) { @@ -133,7 +137,7 @@ public function setUrl($url) * * @param string $image * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setImage($image) { @@ -145,7 +149,7 @@ public function setImage($image) * * @param string $siteName * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setSiteName($siteName) { @@ -157,7 +161,7 @@ public function setSiteName($siteName) * * @param string $locale * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setLocale($locale) { @@ -169,7 +173,7 @@ public function setLocale($locale) * * @param array $locales * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function setAlternativeLocales(array $locales) { @@ -181,7 +185,7 @@ public function setAlternativeLocales(array $locales) * * @param array $properties * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function addProperties(array $properties) { @@ -196,7 +200,7 @@ public function addProperties(array $properties) * @param string $property * @param string|array $content * - * @return \Arcanedev\SeoHelper\Entities\OpenGraph\Graph + * @return $this */ public function addProperty($property, $content) { diff --git a/src/Entities/OpenGraph/MetaCollection.php b/src/Entities/OpenGraph/MetaCollection.php index ac46955..0efe2f0 100644 --- a/src/Entities/OpenGraph/MetaCollection.php +++ b/src/Entities/OpenGraph/MetaCollection.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities\OpenGraph; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities\OpenGraph; use Arcanedev\SeoHelper\Bases\MetaCollection as BaseMetaCollection; diff --git a/src/Entities/Title.php b/src/Entities/Title.php index fb84d01..4fb2e7b 100644 --- a/src/Entities/Title.php +++ b/src/Entities/Title.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\Html\Elements\Element; use Arcanedev\SeoHelper\Contracts\Entities\Title as TitleContract; @@ -118,7 +122,7 @@ public function getTitleOnly() * * @param string $title * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function set($title) { @@ -143,7 +147,7 @@ public function getSiteName() * * @param string $siteName * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function setSiteName($siteName) { @@ -156,7 +160,7 @@ public function setSiteName($siteName) /** * Hide the site name. * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function hideSiteName() { @@ -166,7 +170,7 @@ public function hideSiteName() /** * Show the site name. * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function showSiteName() { @@ -178,7 +182,7 @@ public function showSiteName() * * @param bool $visible * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function setSiteNameVisibility($visible) { @@ -202,7 +206,7 @@ public function getSeparator() * * @param string $separator * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function setSeparator($separator) { @@ -215,7 +219,7 @@ public function setSeparator($separator) /** * Set title first. * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function setFirst() { @@ -225,7 +229,7 @@ public function setFirst() /** * Set title last. * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function setLast() { @@ -237,7 +241,7 @@ public function setLast() * * @param bool $first * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ private function switchPosition($first) { @@ -271,7 +275,7 @@ public function getMax() * * @param int $max * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public function setMax($max) { @@ -294,7 +298,7 @@ public function setMax($max) * @param string $siteName * @param string $separator * - * @return \Arcanedev\SeoHelper\Entities\Title + * @return $this */ public static function make($title, $siteName = '', $separator = '-') { diff --git a/src/Entities/Twitter/Card.php b/src/Entities/Twitter/Card.php index c8535a9..a07bb72 100644 --- a/src/Entities/Twitter/Card.php +++ b/src/Entities/Twitter/Card.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities\Twitter; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities\Twitter; use Arcanedev\SeoHelper\Contracts\Entities\TwitterCard as CardContract; use Arcanedev\SeoHelper\Exceptions\InvalidTwitterCardException; @@ -67,7 +71,7 @@ public function __construct(array $configs = []) /** * Start the engine. * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ private function init() { @@ -90,7 +94,7 @@ private function init() * * @param string $prefix * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ private function setPrefix($prefix) { @@ -104,7 +108,7 @@ private function setPrefix($prefix) * * @param string $type * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function setType($type) { @@ -121,7 +125,7 @@ public function setType($type) * * @param string $site * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function setSite($site) { @@ -137,7 +141,7 @@ public function setSite($site) * * @param string $title * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function setTitle($title) { @@ -149,7 +153,7 @@ public function setTitle($title) * * @param string $description * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function setDescription($description) { @@ -161,7 +165,7 @@ public function setDescription($description) * * @param string $url * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function addImage($url) { @@ -177,7 +181,7 @@ public function addImage($url) * * @param array $metas * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function addMetas(array $metas) { @@ -192,7 +196,7 @@ public function addMetas(array $metas) * @param string $name * @param string|array $content * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function addMeta($name, $content) { @@ -224,26 +228,10 @@ public function types() | ----------------------------------------------------------------- */ - /** - * Render card images. - */ - private function loadImages() - { - if (count($this->images) == 1) { - $this->addMeta('image', $this->images[0]); - - return; - } - - foreach ($this->images as $number => $url) { - $this->addMeta("image{$number}", $url); - } - } - /** * Reset the card. * - * @return \Arcanedev\SeoHelper\Entities\Twitter\Card + * @return $this */ public function reset() { @@ -319,6 +307,22 @@ private function checkSite(string &$site): void | ----------------------------------------------------------------- */ + /** + * Render card images. + */ + private function loadImages(): void + { + if (count($this->images) == 1) { + $this->addMeta('image', $this->images[0]); + + return; + } + + foreach ($this->images as $number => $url) { + $this->addMeta("image{$number}", $url); + } + } + /** * Prepare username. * diff --git a/src/Entities/Twitter/MetaCollection.php b/src/Entities/Twitter/MetaCollection.php index b9632b9..b1a42d3 100644 --- a/src/Entities/Twitter/MetaCollection.php +++ b/src/Entities/Twitter/MetaCollection.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities\Twitter; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities\Twitter; use Arcanedev\SeoHelper\Bases\MetaCollection as BaseMetaCollection; diff --git a/src/Entities/Webmasters.php b/src/Entities/Webmasters.php index 2479161..74235b9 100644 --- a/src/Entities/Webmasters.php +++ b/src/Entities/Webmasters.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Entities; use Arcanedev\SeoHelper\Contracts\Entities\Webmasters as WebmastersContract; use Arcanedev\Support\Traits\Configurable; diff --git a/src/Exceptions/InvalidArgumentException.php b/src/Exceptions/InvalidArgumentException.php index c1dee6c..af749a6 100644 --- a/src/Exceptions/InvalidArgumentException.php +++ b/src/Exceptions/InvalidArgumentException.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Exceptions; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Exceptions; /** * Class InvalidArgumentException diff --git a/src/Exceptions/InvalidTwitterCardException.php b/src/Exceptions/InvalidTwitterCardException.php index dc2339b..d745072 100644 --- a/src/Exceptions/InvalidTwitterCardException.php +++ b/src/Exceptions/InvalidTwitterCardException.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Exceptions; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Exceptions; /** * Class InvalidTwitterCardException diff --git a/src/Exceptions/SeoHelperException.php b/src/Exceptions/SeoHelperException.php index bb6b3a0..477b8f8 100644 --- a/src/Exceptions/SeoHelperException.php +++ b/src/Exceptions/SeoHelperException.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Exceptions; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Exceptions; /** * Class SeoHelperException diff --git a/src/Helpers/Meta.php b/src/Helpers/Meta.php index acb6b74..57d5880 100644 --- a/src/Helpers/Meta.php +++ b/src/Helpers/Meta.php @@ -89,7 +89,7 @@ public function key() * * @param string $prefix * - * @return \Arcanedev\SeoHelper\Helpers\Meta + * @return $this */ public function setPrefix($prefix) { @@ -103,7 +103,7 @@ public function setPrefix($prefix) * * @param string $nameProperty * - * @return \Arcanedev\SeoHelper\Helpers\Meta + * @return $this */ public function setNameProperty($nameProperty) { @@ -132,7 +132,7 @@ private function getName($prefixed = true) * * @param string $name * - * @return \Arcanedev\SeoHelper\Helpers\Meta + * @return $this */ private function setName($name) { @@ -159,7 +159,7 @@ private function getContent() * * @param string|array $content * - * @return \Arcanedev\SeoHelper\Helpers\Meta + * @return $this */ private function setContent($content) { @@ -172,9 +172,10 @@ private function setContent($content) } /* ----------------------------------------------------------------- - | Main Functions + | Main Methods | ----------------------------------------------------------------- */ + /** * Make Meta instance. * @@ -183,7 +184,7 @@ private function setContent($content) * @param string $propertyName * @param string $prefix * - * @return \Arcanedev\SeoHelper\Helpers\Meta + * @return $this */ public static function make($name, $content, $propertyName = 'name', $prefix = '') { diff --git a/src/SeoHelper.php b/src/SeoHelper.php index d50da67..2a4f509 100644 --- a/src/SeoHelper.php +++ b/src/SeoHelper.php @@ -1,9 +1,15 @@ -<?php namespace Arcanedev\SeoHelper; +<?php -use Arcanedev\SeoHelper\Contracts\SeoHelper as SeoHelperContract; -use Arcanedev\SeoHelper\Contracts\SeoMeta as SeoMetaContract; -use Arcanedev\SeoHelper\Contracts\SeoOpenGraph as SeoOpenGraphContract; -use Arcanedev\SeoHelper\Contracts\SeoTwitter as SeoTwitterContract; +declare(strict_types=1); + +namespace Arcanedev\SeoHelper; + +use Arcanedev\SeoHelper\Contracts\{ + SeoHelper as SeoHelperContract, + SeoMeta as SeoMetaContract, + SeoOpenGraph as SeoOpenGraphContract, + SeoTwitter as SeoTwitterContract +}; use Illuminate\Support\HtmlString; /** @@ -53,9 +59,7 @@ class SeoHelper implements SeoHelperContract * @param \Arcanedev\SeoHelper\Contracts\SeoTwitter $seoTwitter */ public function __construct( - SeoMetaContract $seoMeta, - SeoOpenGraphContract $seoOpenGraph, - SeoTwitterContract $seoTwitter + SeoMetaContract $seoMeta, SeoOpenGraphContract $seoOpenGraph, SeoTwitterContract $seoTwitter ) { $this->setSeoMeta($seoMeta); $this->setSeoOpenGraph($seoOpenGraph); @@ -82,7 +86,7 @@ public function meta() * * @param \Arcanedev\SeoHelper\Contracts\SeoMeta $seoMeta * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setSeoMeta(SeoMetaContract $seoMeta) { @@ -118,7 +122,7 @@ public function og() * * @param \Arcanedev\SeoHelper\Contracts\SeoOpenGraph $seoOpenGraph * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setSeoOpenGraph(SeoOpenGraphContract $seoOpenGraph) { @@ -142,7 +146,7 @@ public function twitter() * * @param \Arcanedev\SeoHelper\Contracts\SeoTwitter $seoTwitter * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setSeoTwitter(SeoTwitterContract $seoTwitter) { @@ -158,7 +162,7 @@ public function setSeoTwitter(SeoTwitterContract $seoTwitter) * @param string|null $siteName * @param string|null $separator * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setTitle($title, $siteName = null, $separator = null) { @@ -229,7 +233,7 @@ public function setDescription($description) * * @param array|string $keywords * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setKeywords($keywords) { @@ -243,7 +247,7 @@ public function setKeywords($keywords) * * @param string $imageUrl * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setImage($imageUrl) { @@ -255,10 +259,10 @@ public function setImage($imageUrl) /** * Set the current URL. - * + * * @param string $url * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function setUrl($url) { @@ -312,7 +316,7 @@ public function __toString() /** * Enable the OpenGraph. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function enableOpenGraph() { @@ -324,7 +328,7 @@ public function enableOpenGraph() /** * Disable the OpenGraph. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function disableOpenGraph() { @@ -336,7 +340,7 @@ public function disableOpenGraph() /** * Enable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function enableTwitter() { @@ -348,7 +352,7 @@ public function enableTwitter() /** * Disable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoHelper + * @return $this */ public function disableTwitter() { diff --git a/src/SeoHelperServiceProvider.php b/src/SeoHelperServiceProvider.php index 0083d4d..eb7cdc3 100644 --- a/src/SeoHelperServiceProvider.php +++ b/src/SeoHelperServiceProvider.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper; use Arcanedev\Support\Providers\PackageServiceProvider as ServiceProvider; use Illuminate\Contracts\Support\DeferrableProvider; diff --git a/src/SeoMeta.php b/src/SeoMeta.php index 86f4e7b..aea4c69 100644 --- a/src/SeoMeta.php +++ b/src/SeoMeta.php @@ -1,11 +1,17 @@ -<?php namespace Arcanedev\SeoHelper; - -use Arcanedev\SeoHelper\Contracts\Entities\Analytics as AnalyticsContract; -use Arcanedev\SeoHelper\Contracts\Entities\Description as DescriptionContract; -use Arcanedev\SeoHelper\Contracts\Entities\Keywords as KeywordsContract; -use Arcanedev\SeoHelper\Contracts\Entities\MiscTags as MiscTagsContract; -use Arcanedev\SeoHelper\Contracts\Entities\Title as TitleContract; -use Arcanedev\SeoHelper\Contracts\Entities\Webmasters as WebmastersContract; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper; + +use Arcanedev\SeoHelper\Contracts\Entities\{ + Analytics as AnalyticsContract, + Description as DescriptionContract, + Keywords as KeywordsContract, + MiscTags as MiscTagsContract, + Title as TitleContract, + Webmasters as WebmastersContract +}; use Arcanedev\SeoHelper\Contracts\SeoMeta as SeoMetaContract; use Arcanedev\Support\Traits\Configurable; @@ -97,7 +103,7 @@ public function __construct(array $configs) /** * Start the engine. */ - private function init() + private function init(): void { $this->title( new Entities\Title($this->getConfig('title', [])) @@ -289,7 +295,7 @@ public function setTitle($title, $siteName = null, $separator = null) * * @param string $siteName * - * @return self + * @return $this */ public function setSiteName($siteName) { @@ -313,7 +319,7 @@ public function hideSiteName() /** * Show site name. * - * @return self + * @return $this */ public function showSiteName() { diff --git a/src/SeoOpenGraph.php b/src/SeoOpenGraph.php index 5fadb71..7059444 100644 --- a/src/SeoOpenGraph.php +++ b/src/SeoOpenGraph.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper; use Arcanedev\SeoHelper\Contracts\Entities\OpenGraph as OpenGraphContract; use Arcanedev\SeoHelper\Contracts\SeoOpenGraph as SeoOpenGraphContract; @@ -63,20 +67,6 @@ public function __construct(array $configs) | ----------------------------------------------------------------- */ - /** - * Set the enabled status for the OpenGraph. - * - * @param bool $enabled - * - * @return \Arcanedev\SeoHelper\SeoOpenGraph - */ - private function setEnabled($enabled) - { - $this->enabled = $enabled; - - return $this; - } - /** * Set the Open Graph instance. * @@ -246,6 +236,20 @@ public function addProperty($property, $content) return $this; } + /** + * Set the enabled status for the OpenGraph. + * + * @param bool $enabled + * + * @return \Arcanedev\SeoHelper\SeoOpenGraph + */ + private function setEnabled(bool $enabled) + { + $this->enabled = $enabled; + + return $this; + } + /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- diff --git a/src/SeoTwitter.php b/src/SeoTwitter.php index 3140074..4d3482c 100644 --- a/src/SeoTwitter.php +++ b/src/SeoTwitter.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper; use Arcanedev\SeoHelper\Contracts\Entities\TwitterCard as CardContract; use Arcanedev\SeoHelper\Contracts\SeoTwitter as SeoTwitterContract; @@ -65,26 +69,12 @@ public function __construct(array $configs) | ----------------------------------------------------------------- */ - /** - * Set the enabled status for the Twitter Card. - * - * @param bool $enabled - * - * @return \Arcanedev\SeoHelper\SeoTwitter - */ - private function setEnabled($enabled) - { - $this->enabled = (bool) $enabled; - - return $this; - } - /** * Set the Twitter Card instance. * * @param \Arcanedev\SeoHelper\Contracts\Entities\TwitterCard $card * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setCard(CardContract $card) { @@ -98,7 +88,7 @@ public function setCard(CardContract $card) * * @param string $type * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setType($type) { @@ -112,7 +102,7 @@ public function setType($type) * * @param string $site * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setSite($site) { @@ -126,7 +116,7 @@ public function setSite($site) * * @param string $title * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setTitle($title) { @@ -140,7 +130,7 @@ public function setTitle($title) * * @param string $description * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function setDescription($description) { @@ -154,7 +144,7 @@ public function setDescription($description) * * @param string $url * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function addImage($url) { @@ -168,7 +158,7 @@ public function addImage($url) * * @param array $metas * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function addMetas(array $metas) { @@ -183,7 +173,7 @@ public function addMetas(array $metas) * @param string $name * @param string $content * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function addMeta($name, $content) { @@ -192,6 +182,20 @@ public function addMeta($name, $content) return $this; } + /** + * Set the enabled status for the Twitter Card. + * + * @param bool $enabled + * + * @return $this + */ + private function setEnabled(bool $enabled) + { + $this->enabled = $enabled; + + return $this; + } + /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- @@ -200,7 +204,7 @@ public function addMeta($name, $content) /** * Reset the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function reset() { @@ -232,7 +236,7 @@ public function __toString() /** * Enable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function enable() { @@ -242,7 +246,7 @@ public function enable() /** * Disable the Twitter Card. * - * @return \Arcanedev\SeoHelper\SeoTwitter + * @return $this */ public function disable() { diff --git a/src/Traits/Seoable.php b/src/Traits/Seoable.php index a4d54fb..a86d6df 100644 --- a/src/Traits/Seoable.php +++ b/src/Traits/Seoable.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Traits; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Traits; /** * Trait Seoable diff --git a/tests/Asserts/AssertsHtmlStrings.php b/tests/Asserts/AssertsHtmlStrings.php index 10fa884..fa0a871 100644 --- a/tests/Asserts/AssertsHtmlStrings.php +++ b/tests/Asserts/AssertsHtmlStrings.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Asserts; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Asserts; use DOMDocument; @@ -18,15 +22,15 @@ trait AssertsHtmlStrings /** * Assert two Html strings are equals. * - * @param string $expected - * @param string $actual - * @param string $message + * @param string $expected + * @param string|mixed $actual + * @param string $message */ - public static function assertHtmlStringEqualsHtmlString(string $expected, string $actual, string $message = '') + public static function assertHtmlStringEqualsHtmlString(string $expected, $actual, string $message = ''): void { static::assertEqualsCanonicalizing( static::convertToDomDocument($expected), - static::convertToDomDocument($actual), + static::convertToDomDocument((string) $actual), $message ); } @@ -43,7 +47,7 @@ public static function assertHtmlStringEqualsHtmlString(string $expected, string * * @return \DOMDocument */ - protected static function convertToDomDocument($html) + protected static function convertToDomDocument($html): DOMDocument { return tap(new DOMDocument, function (DOMDocument $dom) use ($html) { $dom->loadHTML(preg_replace('/>\s+</', '><', $html)); diff --git a/tests/Entities/AnalyticsTest.php b/tests/Entities/AnalyticsTest.php index f79eed8..a214dd6 100644 --- a/tests/Entities/AnalyticsTest.php +++ b/tests/Entities/AnalyticsTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; use Arcanedev\SeoHelper\Entities\Analytics; use Arcanedev\SeoHelper\Tests\TestCase; @@ -45,7 +49,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Renderable::class, @@ -59,7 +63,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_must_render_empty_on_init() + public function it_must_render_empty_on_init(): void { $this->analytics = new Analytics; @@ -67,7 +71,7 @@ public function it_must_render_empty_on_init() } /** @test */ - public function it_can_render() + public function it_can_render(): void { $expectations = [ '<script>', diff --git a/tests/Entities/DescriptionTest.php b/tests/Entities/DescriptionTest.php index cf89259..4c4dd23 100644 --- a/tests/Entities/DescriptionTest.php +++ b/tests/Entities/DescriptionTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; use Arcanedev\SeoHelper\Entities\Description; use Arcanedev\SeoHelper\Tests\TestCase; @@ -46,7 +50,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Entities\Description::class, @@ -60,7 +64,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_make() + public function it_can_make(): void { $this->description = Description::make('Cool description about this package'); @@ -76,7 +80,7 @@ public function it_can_make() } /** @test */ - public function it_can_get_default_description() + public function it_can_get_default_description(): void { $content = $this->getDefaultContent(); @@ -84,7 +88,7 @@ public function it_can_get_default_description() } /** @test */ - public function it_can_set_and_get_content() + public function it_can_set_and_get_content(): void { $content = 'Cool description about this package'; @@ -94,7 +98,7 @@ public function it_can_set_and_get_content() } /** @test */ - public function it_can_set_and_get_max_length() + public function it_can_set_and_get_max_length(): void { $max = 150; @@ -104,7 +108,7 @@ public function it_can_set_and_get_max_length() } /** @test */ - public function it_must_throw_invalid_max_length_type() + public function it_must_throw_invalid_max_length_type(): void { $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); $this->expectExceptionMessage('The description maximum length must be integer.'); @@ -113,7 +117,7 @@ public function it_must_throw_invalid_max_length_type() } /** @test */ - public function it_must_throw_invalid_max_length_value() + public function it_must_throw_invalid_max_length_value(): void { $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); $this->expectExceptionMessage('The description maximum length must be greater 0.'); @@ -122,7 +126,7 @@ public function it_must_throw_invalid_max_length_value() } /** @test */ - public function it_can_render() + public function it_can_render(): void { $this->description->set( $description = 'Cool description about this package' @@ -135,7 +139,7 @@ public function it_can_render() } /** @test */ - public function it_can_render_empty_description() + public function it_can_render_empty_description(): void { $this->description->set(''); @@ -144,7 +148,7 @@ public function it_can_render_empty_description() } /** @test */ - public function it_can_render_long_title() + public function it_can_render_long_title(): void { $content = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, ullamco laboris aliquip commodo.'; $max = $this->getDefaultMax(); @@ -167,7 +171,7 @@ public function it_can_render_long_title() * * @return array */ - private function getDescriptionConfig() + private function getDescriptionConfig(): array { return $this->getSeoHelperConfig('description', []); } @@ -179,7 +183,7 @@ private function getDescriptionConfig() * * @return string */ - private function getDefaultContent($default = '') + private function getDefaultContent($default = ''): string { return $this->getSeoHelperConfig('description.default', $default); } @@ -191,7 +195,7 @@ private function getDefaultContent($default = '') * * @return int */ - private function getDefaultMax($default = 155) + private function getDefaultMax($default = 155): int { return $this->getSeoHelperConfig('description.max', $default); } diff --git a/tests/Entities/KeywordsTest.php b/tests/Entities/KeywordsTest.php index 16395aa..75b36df 100644 --- a/tests/Entities/KeywordsTest.php +++ b/tests/Entities/KeywordsTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; use Arcanedev\SeoHelper\Entities\Keywords; use Arcanedev\SeoHelper\Tests\TestCase; @@ -45,7 +49,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Renderable::class, @@ -59,7 +63,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_get_default_content() + public function it_can_get_default_content(): void { $content = $this->getDefaultContent(); @@ -68,7 +72,7 @@ public function it_can_get_default_content() } /** @test */ - public function it_can_set_and_get_content() + public function it_can_set_and_get_content(): void { $content = $this->getDefaultContent(); @@ -95,7 +99,7 @@ public function it_can_set_and_get_content() } /** @test */ - public function it_can_add_a_keyword() + public function it_can_add_a_keyword(): void { $content = $this->getDefaultContent(); @@ -112,7 +116,7 @@ public function it_can_add_a_keyword() } /** @test */ - public function it_can_add_many_keywords() + public function it_can_add_many_keywords(): void { $content = $this->getDefaultContent(); @@ -131,7 +135,7 @@ public function it_can_add_many_keywords() } /** @test */ - public function it_can_render() + public function it_can_render(): void { $content = $this->getDefaultContent(); $expected = '<meta name="keywords" content="'.implode(', ', $content).'">'; @@ -166,7 +170,7 @@ public function it_can_render() } /** @test */ - public function it_can_make() + public function it_can_make(): void { $keywords = $this->getDefaultContent(); $this->keywords = Keywords::make($keywords); @@ -189,7 +193,7 @@ public function it_can_make() * * @return array */ - private function getKeywordsConfig() + private function getKeywordsConfig(): array { return $this->getSeoHelperConfig('keywords', []); } diff --git a/tests/Entities/MetaCollectionTest.php b/tests/Entities/MetaCollectionTest.php index 091136b..f70c5c9 100644 --- a/tests/Entities/MetaCollectionTest.php +++ b/tests/Entities/MetaCollectionTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; use Arcanedev\SeoHelper\Entities\MetaCollection; use Arcanedev\SeoHelper\Tests\TestCase; @@ -44,7 +48,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Entities\MetaCollection::class, @@ -60,7 +64,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_add_meta() + public function it_can_add_meta(): void { $this->metas->addOne('robots', 'noindex, nofollow'); @@ -72,7 +76,7 @@ public function it_can_add_meta() } /** @test */ - public function it_can_render_meta_tags() + public function it_can_render_meta_tags(): void { $this->metas->addOne('robots', 'noindex, nofollow'); @@ -83,7 +87,7 @@ public function it_can_render_meta_tags() } /** @test */ - public function it_can_render_link_tags() + public function it_can_render_link_tags(): void { $this->metas->addOne('canonical', $this->baseUrl); diff --git a/tests/Entities/MiscTagsTest.php b/tests/Entities/MiscTagsTest.php index b719772..eb96dbb 100644 --- a/tests/Entities/MiscTagsTest.php +++ b/tests/Entities/MiscTagsTest.php @@ -1,6 +1,9 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; -use Arcanedev\SeoHelper\Contracts\Renderable; use Arcanedev\SeoHelper\Entities\MiscTags; use Arcanedev\SeoHelper\Tests\TestCase; @@ -48,7 +51,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Entities\MiscTags::class, @@ -62,7 +65,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_render_canonical() + public function it_can_render_canonical(): void { $this->misc->setUrl($url = 'http://laravel.com'); @@ -78,7 +81,7 @@ public function it_can_render_canonical() } /** @test */ - public function it_can_render_robots() + public function it_can_render_robots(): void { $expected = '<meta name="robots" content="noindex, nofollow">'; @@ -92,7 +95,7 @@ public function it_can_render_robots() } /** @test */ - public function it_can_render_links() + public function it_can_render_links(): void { $author = 'https://plus.google.com/+AuthorProfile'; $publisher = 'https://plus.google.com/+PublisherProfile'; @@ -113,7 +116,7 @@ public function it_can_render_links() } /** @test */ - public function it_can_render() + public function it_can_render(): void { $robots = '<meta name="robots" content="noindex, nofollow">'; $canonical = '<link rel="canonical" href="'.$this->baseUrl.'">'; @@ -150,7 +153,7 @@ public function it_can_render() } /** @test */ - public function it_can_add_remove_and_reset_tags() + public function it_can_add_remove_and_reset_tags(): void { static::assertNotEmpty($this->misc->render()); @@ -215,7 +218,7 @@ public function it_can_add_remove_and_reset_tags() } /** @test */ - public function it_can_make() + public function it_can_make(): void { $this->misc = MiscTags::make([ 'copyright' => 'ARCANEDEV', @@ -251,7 +254,7 @@ public function it_can_make() * * @return array */ - private function getMiscConfig() + private function getMiscConfig(): array { return $this->getSeoHelperConfig('misc', []); } diff --git a/tests/Entities/OpenGraph/GraphTest.php b/tests/Entities/OpenGraph/GraphTest.php index 3b7784a..a4dbf62 100644 --- a/tests/Entities/OpenGraph/GraphTest.php +++ b/tests/Entities/OpenGraph/GraphTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities\OpenGraph; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities\OpenGraph; use Arcanedev\SeoHelper\Entities\OpenGraph\Graph; use Arcanedev\SeoHelper\Tests\TestCase; @@ -45,7 +49,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Entities\OpenGraph\Graph::class, @@ -59,7 +63,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_render_defaults() + public function it_can_render_defaults(): void { $output = $this->og->render(); $expected = '<meta property="og:type" content="website">'. @@ -70,7 +74,7 @@ public function it_can_render_defaults() } /** @test */ - public function it_can_set_and_render_type() + public function it_can_set_and_render_type(): void { $types = [ 'article', @@ -90,7 +94,7 @@ public function it_can_set_and_render_type() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; @@ -103,7 +107,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'Hello World detailed description.'; @@ -116,7 +120,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_url() + public function it_can_set_and_render_url(): void { $url = 'http://www.imdb.com/title/tt0080339/'; @@ -129,7 +133,7 @@ public function it_can_set_and_render_url() } /** @test */ - public function it_can_set_and_render_image() + public function it_can_set_and_render_image(): void { $image = 'http://ia.media-imdb.com/images/M/MV5BNDU2MjE4MTcwNl5BMl5BanBnXkFtZTgwNDExOTMxMDE@._V1_UY1200_CR90,0,630,1200_AL_.jpg'; @@ -142,7 +146,7 @@ public function it_can_set_and_render_image() } /** @test */ - public function it_can_set_and_render_site_name() + public function it_can_set_and_render_site_name(): void { $siteName = 'My site name'; @@ -155,7 +159,7 @@ public function it_can_set_and_render_site_name() } /** @test */ - public function it_can_add_render_property() + public function it_can_add_render_property(): void { $locale = 'en_GB'; @@ -168,7 +172,7 @@ public function it_can_add_render_property() } /** @test */ - public function it_can_add_render_properties() + public function it_can_add_render_properties(): void { $properties = [ 'locale' => 'en_GB', @@ -190,7 +194,7 @@ public function it_can_add_render_properties() } /** @test */ - public function it_can_set_and_render_locale_property() + public function it_can_set_and_render_locale_property(): void { $locales = ['fr_FR', 'en_GB', 'es_ES']; @@ -203,7 +207,7 @@ public function it_can_set_and_render_locale_property() } /** @test */ - public function it_can_set_and_render_alternative_properties() + public function it_can_set_and_render_alternative_properties(): void { $this->og->setAlternativeLocales(['fr_FR', 'en_GB', 'es_ES']); diff --git a/tests/Entities/TitleTest.php b/tests/Entities/TitleTest.php index 8ee85e4..7884935 100644 --- a/tests/Entities/TitleTest.php +++ b/tests/Entities/TitleTest.php @@ -1,6 +1,11 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; use Arcanedev\SeoHelper\Entities\Title; +use Arcanedev\SeoHelper\Exceptions\InvalidArgumentException; use Arcanedev\SeoHelper\Tests\TestCase; use Illuminate\Support\Arr; use Illuminate\Support\Str; @@ -47,7 +52,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Renderable::class, @@ -61,7 +66,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_get_default_title() + public function it_can_get_default_title(): void { static::assertSame( $this->getDefaultTitle(), @@ -70,7 +75,7 @@ public function it_can_get_default_title() } /** @test */ - public function it_can_set_and_get_title() + public function it_can_set_and_get_title(): void { $title = 'Awesome Title'; @@ -80,7 +85,7 @@ public function it_can_set_and_get_title() } /** @test */ - public function it_can_get_default_site_name() + public function it_can_get_default_site_name(): void { static::assertSame( $this->getDefaultSiteName(), @@ -89,7 +94,7 @@ public function it_can_get_default_site_name() } /** @test */ - public function it_can_set_and_get_site_name() + public function it_can_set_and_get_site_name(): void { $siteName = 'Company name'; @@ -99,7 +104,7 @@ public function it_can_set_and_get_site_name() } /** @test */ - public function it_can_get_default_separator() + public function it_can_get_default_separator(): void { static::assertSame( $this->getDefaultSeparator(), @@ -108,7 +113,7 @@ public function it_can_get_default_separator() } /** @test */ - public function it_can_get_and_set_separator() + public function it_can_get_and_set_separator(): void { $separator = '|'; $this->title->setSeparator($separator); @@ -122,7 +127,7 @@ public function it_can_get_and_set_separator() } /** @test */ - public function it_can_get_default_title_position() + public function it_can_get_default_title_position(): void { static::assertSame( Arr::get($this->getTitleConfig(), 'first', true), @@ -131,7 +136,7 @@ public function it_can_get_default_title_position() } /** @test */ - public function it_can_switch_title_position() + public function it_can_switch_title_position(): void { static::assertTrue($this->title->isTitleFirst()); @@ -145,7 +150,7 @@ public function it_can_switch_title_position() } /** @test */ - public function it_can_render_default_title() + public function it_can_render_default_title(): void { $title = $this->getDefaultTitle(); $siteName = $this->getDefaultSiteName(); @@ -156,7 +161,7 @@ public function it_can_render_default_title() } /** @test */ - public function it_can_render_custom_titles() + public function it_can_render_custom_titles(): void { $title = 'Awesome Title'; $siteName = 'Company name'; @@ -221,7 +226,7 @@ public function it_can_render_custom_titles() } /** @test */ - public function it_can_make_title_tag() + public function it_can_make_title_tag(): void { $title = 'Awesome title'; $siteName = 'Company Name'; @@ -242,7 +247,7 @@ public function it_can_make_title_tag() } /** @test */ - public function it_can_toggle_site_name_visibility() + public function it_can_toggle_site_name_visibility(): void { $title = 'Awesome title'; $siteName = 'Company Name'; @@ -271,25 +276,25 @@ public function it_can_toggle_site_name_visibility() } /** @test */ - public function it_must_throw_title_exception_on_invalid_type() + public function it_must_throw_title_exception_on_invalid_type(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The title must be a string value, [NULL] is given.'); $this->title->set(null); } /** @test */ - public function it_must_throw_title_exception_on_empty_title() + public function it_must_throw_title_exception_on_empty_title(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The title is required and must not be empty.'); $this->title->set(' '); } /** @test */ - public function it_can_set_and_get_max_length() + public function it_can_set_and_get_max_length(): void { $this->title->setMax($max = 50); @@ -297,7 +302,7 @@ public function it_can_set_and_get_max_length() } /** @test */ - public function it_can_render_long_title() + public function it_can_render_long_title(): void { $title = 'This is my long and awesome title that gonna blown your mind.'; $max = $this->getDefaultMax(); @@ -311,7 +316,7 @@ public function it_can_render_long_title() } /** @test */ - public function it_can_render_title_with_accents() + public function it_can_render_title_with_accents(): void { $this->title->set('Ce package est intuitif, exceptionnel et bien sûr opérationnel'); @@ -322,18 +327,18 @@ public function it_can_render_title_with_accents() } /** @test */ - public function it_must_throw_invalid_max_length_type() + public function it_must_throw_invalid_max_length_type(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The title maximum length must be integer.'); $this->title->setMax(null); } /** @test */ - public function it_must_throw_invalid_max_length_value() + public function it_must_throw_invalid_max_length_value(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The title maximum length must be greater 0.'); $this->title->setMax(0); @@ -349,7 +354,7 @@ public function it_must_throw_invalid_max_length_value() * * @return array */ - private function getTitleConfig() + private function getTitleConfig(): array { return $this->getSeoHelperConfig('title', []); } @@ -361,7 +366,7 @@ private function getTitleConfig() * * @return string */ - private function getDefaultTitle($default = '') + private function getDefaultTitle($default = ''): string { return $this->getSeoHelperConfig('title.default', $default); } @@ -373,7 +378,7 @@ private function getDefaultTitle($default = '') * * @return string */ - private function getDefaultSiteName($default = '') + private function getDefaultSiteName($default = ''): string { return $this->getSeoHelperConfig('title.site-name', $default); } @@ -385,7 +390,7 @@ private function getDefaultSiteName($default = '') * * @return string */ - private function getDefaultSeparator($default = '-') + private function getDefaultSeparator($default = '-'): string { return $this->getSeoHelperConfig('title.separator', $default); } @@ -397,7 +402,7 @@ private function getDefaultSeparator($default = '-') * * @return int */ - private function getDefaultMax($default = 55) + private function getDefaultMax($default = 55): int { return $this->getSeoHelperConfig('title.max', $default); } diff --git a/tests/Entities/Twitter/CardTest.php b/tests/Entities/Twitter/CardTest.php index b7fd2dc..5fdb397 100644 --- a/tests/Entities/Twitter/CardTest.php +++ b/tests/Entities/Twitter/CardTest.php @@ -1,6 +1,11 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities\Twitter; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities\Twitter; use Arcanedev\SeoHelper\Entities\Twitter\Card; +use Arcanedev\SeoHelper\Exceptions\InvalidTwitterCardException; use Arcanedev\SeoHelper\Tests\TestCase; /** @@ -45,7 +50,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Renderable::class, @@ -59,7 +64,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_set_type_and_render() + public function it_can_set_type_and_render(): void { $supported = [ 'app', 'gallery', 'photo', 'player', 'product', 'summary', 'summary_large_image' @@ -76,25 +81,25 @@ public function it_can_set_type_and_render() } /** @test */ - public function it_must_throw_invalid_twitter_card_exception_on_invalid_type() + public function it_must_throw_invalid_twitter_card_exception_on_invalid_type(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidTwitterCardException::class); + $this->expectException(InvalidTwitterCardException::class); $this->expectExceptionMessage('The Twitter card type must be a string value, [boolean] was given.'); $this->card->setType(true); } /** @test */ - public function it_must_throw_invalid_twitter_card_exception_on_unsupported_type() + public function it_must_throw_invalid_twitter_card_exception_on_unsupported_type(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidTwitterCardException::class); + $this->expectException(InvalidTwitterCardException::class); $this->expectExceptionMessage('The Twitter card type [selfie] is not supported.'); $this->card->setType('selfie'); } /** @test */ - public function it_can_set_prefix() + public function it_can_set_prefix(): void { $prefix = 'twt:'; $this->card = new Card([ @@ -109,7 +114,7 @@ public function it_can_set_prefix() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello world'; $this->card->setTitle($title); @@ -121,7 +126,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'Hello world description'; $this->card->setDescription($description); @@ -133,7 +138,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_site() + public function it_can_set_and_render_site(): void { $site = 'Arcanedev'; $excepted = '<meta name="twitter:site" content="@'.$site.'">'; @@ -150,7 +155,7 @@ public function it_can_set_and_render_site() } /** @test */ - public function it_can_add_and_render_one_image() + public function it_can_add_and_render_one_image(): void { $avatar = 'http://example.com/img/avatar.png'; $this->card->addImage($avatar); @@ -161,7 +166,7 @@ public function it_can_add_and_render_one_image() } /** @test */ - public function it_can_add_and_render_multiple_images() + public function it_can_add_and_render_multiple_images(): void { $avatar = 'http://example.com/img/avatar.png'; $number = range(0, 4); @@ -180,7 +185,7 @@ public function it_can_add_and_render_multiple_images() } /** @test */ - public function it_can_add_and_render_many_metas() + public function it_can_add_and_render_many_metas(): void { $metas = [ 'creator' => '@Arcanedev', @@ -202,7 +207,7 @@ public function it_can_add_and_render_many_metas() } /** @test */ - public function it_can_reset() + public function it_can_reset(): void { $expected = $this->card->render(); diff --git a/tests/Entities/WebmastersTest.php b/tests/Entities/WebmastersTest.php index 8c92620..f48c138 100644 --- a/tests/Entities/WebmastersTest.php +++ b/tests/Entities/WebmastersTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Entities; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Entities; use Arcanedev\SeoHelper\Entities\Webmasters; use Arcanedev\SeoHelper\Tests\TestCase; @@ -45,7 +49,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Entities\Webmasters::class, @@ -59,7 +63,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_render_defaults() + public function it_can_render_defaults(): void { $expectations = [ '<meta name="google-site-verification" content="site-verification-code">', @@ -76,7 +80,7 @@ public function it_can_render_defaults() } /** @test */ - public function it_can_make_and_add() + public function it_can_make_and_add(): void { $this->webmasters = Webmasters::make([ 'google' => 'site-verification-code' @@ -96,7 +100,7 @@ public function it_can_make_and_add() } /** @test */ - public function it_can_skip_unsupported_webmasters() + public function it_can_skip_unsupported_webmasters(): void { $this->webmasters = Webmasters::make([ 'duckduckgo' => 'site-verification-code' @@ -107,7 +111,7 @@ public function it_can_skip_unsupported_webmasters() } /** @test */ - public function it_can_reset() + public function it_can_reset(): void { static::assertNotEmpty($this->webmasters->render()); static::assertNotEmpty((string) $this->webmasters); diff --git a/tests/Helpers/MetaTest.php b/tests/Helpers/MetaTest.php index f8944be..865e42d 100644 --- a/tests/Helpers/MetaTest.php +++ b/tests/Helpers/MetaTest.php @@ -1,5 +1,10 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Helpers; +<?php +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Helpers; + +use Arcanedev\SeoHelper\Exceptions\InvalidArgumentException; use Arcanedev\SeoHelper\Helpers\Meta; use Arcanedev\SeoHelper\Tests\TestCase; @@ -17,7 +22,7 @@ class MetaTest extends TestCase */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $results = [ Meta::make('name', 'Hello world'), @@ -41,7 +46,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_valid() + public function it_can_valid(): void { $valids = [ Meta::make('name', 'Hello world') @@ -67,7 +72,7 @@ public function it_can_valid() } /** @test */ - public function it_can_render() + public function it_can_render(): void { static::assertSame( '<meta name="name" content="Hello world">', @@ -91,7 +96,7 @@ public function it_can_render() } /** @test */ - public function it_can_make_meta_with_prefix() + public function it_can_make_meta_with_prefix(): void { $meta = Meta::make('hello', 'Hello World', 'name', 'say:'); @@ -109,7 +114,7 @@ public function it_can_make_meta_with_prefix() } /** @test */ - public function it_can_clean_and_render() + public function it_can_clean_and_render(): void { $name = '<b>Awesome name</b>'; $content = 'Harmless <script>alert("Danger Zone");</script>'; @@ -121,7 +126,7 @@ public function it_can_clean_and_render() } /** @test */ - public function it_can_make_meta_with_custom_name_property() + public function it_can_make_meta_with_custom_name_property(): void { $meta = Meta::make('title', 'Hello World', 'property', 'og:'); @@ -132,7 +137,7 @@ public function it_can_make_meta_with_custom_name_property() } /** @test */ - public function it_can_set_name_property() + public function it_can_set_name_property(): void { $meta = Meta::make('title', 'Hello World'); @@ -146,25 +151,25 @@ public function it_can_set_name_property() } /** @test */ - public function it_must_throw_an_invalid_argument_exception_on_invalid_type() + public function it_must_throw_an_invalid_argument_exception_on_invalid_type(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The meta name property is must be a string value, NULL is given.'); Meta::make('title', 'Hello World')->setNameProperty(null); } /** @test */ - public function it_must_throw_an_invalid_argument_exception_on_not_allowed_name() + public function it_must_throw_an_invalid_argument_exception_on_not_allowed_name(): void { - $this->expectException(\Arcanedev\SeoHelper\Exceptions\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The meta name property [foo] is not supported, the allowed name properties are ['charset', 'http-equiv', 'itemprop', 'name', 'property']."); Meta::make('title', 'Hello World')->setNameProperty('foo'); } /** @test */ - public function it_can_render_array_content() + public function it_can_render_array_content(): void { $meta = Meta::make('locale:alternate', ['fr_FR', 'es_ES', 'en_GB']); diff --git a/tests/SeoHelperServiceProviderTest.php b/tests/SeoHelperServiceProviderTest.php index 0f340af..5f6fec7 100644 --- a/tests/SeoHelperServiceProviderTest.php +++ b/tests/SeoHelperServiceProviderTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests; use Arcanedev\SeoHelper\SeoHelperServiceProvider; @@ -43,7 +47,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_get_service_provider() + public function it_can_get_service_provider(): void { $expectations = [ \Illuminate\Support\ServiceProvider::class, @@ -59,7 +63,7 @@ public function it_can_get_service_provider() } /** @test */ - public function it_can_provides() + public function it_can_provides(): void { $expected = [ \Arcanedev\SeoHelper\Contracts\SeoHelper::class, diff --git a/tests/SeoHelperTest.php b/tests/SeoHelperTest.php index 4010a6f..b569813 100644 --- a/tests/SeoHelperTest.php +++ b/tests/SeoHelperTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests; use Arcanedev\SeoHelper\Contracts\SeoHelper as SeoHelperContract; @@ -43,7 +47,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\SeoHelper::class, @@ -57,7 +61,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_be_instantiated_with_helper() + public function it_can_be_instantiated_with_helper(): void { $this->seoHelper = seo_helper(); $expectations = [ @@ -72,7 +76,7 @@ public function it_can_be_instantiated_with_helper() } /** @test */ - public function it_can_get_seo_meta() + public function it_can_get_seo_meta(): void { $seoMeta = $this->seoHelper->meta(); @@ -88,7 +92,7 @@ public function it_can_get_seo_meta() } /** @test */ - public function it_can_get_seo_open_graph() + public function it_can_get_seo_open_graph(): void { $ogs = [ $this->seoHelper->openGraph(), @@ -109,7 +113,7 @@ public function it_can_get_seo_open_graph() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; $siteName = 'ARCANEDEV'; @@ -130,7 +134,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_site_name() + public function it_can_set_and_render_site_name(): void { $title = 'My Application'; $siteName = 'ARCANEDEV'; @@ -151,7 +155,7 @@ public function it_can_set_and_render_site_name() } /** @test */ - public function it_can_toggle_site_name_visibility() + public function it_can_toggle_site_name_visibility(): void { $title = 'My Application'; $siteName = 'ARCANEDEV'; @@ -179,7 +183,7 @@ public function it_can_toggle_site_name_visibility() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'ARCANEDEV super description'; $expectations = [ @@ -197,7 +201,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_keywords() + public function it_can_set_and_render_keywords(): void { $keywords = $this->getSeoHelperConfig('keywords.default'); $expected = '<meta name="keywords" content="'.implode(', ', $keywords).'">'; @@ -214,7 +218,7 @@ public function it_can_set_and_render_keywords() } /** @test */ - public function it_can_set_and_render_image() + public function it_can_set_and_render_image(): void { $this->seoHelper->setImage($imageUrl = 'http://localhost/assets/img/logo.png'); @@ -229,9 +233,9 @@ public function it_can_set_and_render_image() static::assertStringContainsString($expected, $rendered); } } - + /** @test */ - public function it_can_set_and_render_url() + public function it_can_set_and_render_url(): void { $this->seoHelper->setUrl($url = 'http://localhost/path'); @@ -248,7 +252,7 @@ public function it_can_set_and_render_url() } /** @test */ - public function it_can_render_all() + public function it_can_render_all(): void { $output = $this->seoHelper->render(); @@ -256,7 +260,7 @@ public function it_can_render_all() } /** @test */ - public function it_can_render_all_with_html_string_object() + public function it_can_render_all_with_html_string_object(): void { $output = $this->seoHelper->renderHtml(); @@ -265,7 +269,7 @@ public function it_can_render_all_with_html_string_object() } /** @test */ - public function it_can_enable_and_disable_open_graph() + public function it_can_enable_and_disable_open_graph(): void { $needle = '<meta property="og:'; @@ -299,7 +303,7 @@ public function it_can_enable_and_disable_open_graph() } /** @test */ - public function it_can_enable_and_disable_twitter_card() + public function it_can_enable_and_disable_twitter_card(): void { $needle = '<meta name="twitter:'; diff --git a/tests/SeoMetaTest.php b/tests/SeoMetaTest.php index 1a11448..b045025 100644 --- a/tests/SeoMetaTest.php +++ b/tests/SeoMetaTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests; use Arcanedev\SeoHelper\Contracts\SeoMeta as SeoMetaContract; use Arcanedev\SeoHelper\SeoMeta; @@ -47,7 +51,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Renderable::class, @@ -63,7 +67,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_be_instantiated_by_container() + public function it_can_be_instantiated_by_container(): void { $this->seoMeta = $this->app[SeoMetaContract::class]; @@ -73,7 +77,7 @@ public function it_can_be_instantiated_by_container() } /** @test */ - public function it_can_set_and_get_and_render_title() + public function it_can_set_and_get_and_render_title(): void { $title = 'Awesome Title'; $siteName = $this->getSeoHelperConfig('title.site-name'); @@ -118,7 +122,7 @@ public function it_can_set_and_get_and_render_title() } /** @test */ - public function it_can_set_and_get_and_render_description() + public function it_can_set_and_get_and_render_description(): void { $description = 'Awesome Description'; $this->seoMeta->setDescription($description); @@ -143,7 +147,7 @@ public function it_can_set_and_get_and_render_description() } /** @test */ - public function it_can_set_and_get_and_render_keywords() + public function it_can_set_and_get_and_render_keywords(): void { $keywords = ['keyword-1', 'keyword-2', 'keyword-3', 'keyword-4', 'keyword-5']; @@ -183,7 +187,7 @@ public function it_can_set_and_get_and_render_keywords() } /** @test */ - public function it_can_add_one_keyword() + public function it_can_add_one_keyword(): void { $keywords = ['keyword-1', 'keyword-2', 'keyword-3', 'keyword-4', 'keyword-5']; $this->seoMeta->setKeywords($keywords); @@ -203,7 +207,7 @@ public function it_can_add_one_keyword() } /** @test */ - public function it_can_add_many_keywords() + public function it_can_add_many_keywords(): void { $keywords = ['keyword-1', 'keyword-2', 'keyword-3', 'keyword-4', 'keyword-5']; $expected = '<meta name="keywords" content="'.implode(', ', $keywords).'">'; @@ -223,7 +227,7 @@ public function it_can_add_many_keywords() } /** @test */ - public function it_can_add_remove_reset_and_render_a_misc_tag() + public function it_can_add_remove_reset_and_render_a_misc_tag(): void { $expectations = [ '<meta name="robots" content="noindex, nofollow">', @@ -306,7 +310,7 @@ public function it_can_add_remove_reset_and_render_a_misc_tag() } /** @test */ - public function it_can_render_add_reset_webmasters() + public function it_can_render_add_reset_webmasters(): void { $expectations = [ '<meta name="google-site-verification" content="site-verification-code">', @@ -350,7 +354,7 @@ public function it_can_render_add_reset_webmasters() } /** @test */ - public function it_can_set_and_render_google_analytics() + public function it_can_set_and_render_google_analytics(): void { static::assertStringContainsString( "ga('create', 'UA-12345678-9', 'auto');", @@ -386,7 +390,7 @@ public function it_can_set_and_render_google_analytics() * * @param \Arcanedev\SeoHelper\Contracts\Entities\MetaCollection $metas */ - protected static function assertMetaCollection($metas) + protected static function assertMetaCollection($metas): void { $expectations = [ \Arcanedev\SeoHelper\Contracts\Entities\MetaCollection::class, diff --git a/tests/SeoOpenGraphTest.php b/tests/SeoOpenGraphTest.php index 7dcdd8d..6d9dfb1 100644 --- a/tests/SeoOpenGraphTest.php +++ b/tests/SeoOpenGraphTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests; use Arcanedev\SeoHelper\SeoOpenGraph; @@ -44,7 +48,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\SeoOpenGraph::class, @@ -58,7 +62,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_render_defaults() + public function it_can_render_defaults(): void { $expectations = [ '<meta property="og:type" content="website">', @@ -73,7 +77,7 @@ public function it_can_render_defaults() } /** @test */ - public function it_can_set_and_render_prefix() + public function it_can_set_and_render_prefix(): void { $this->seoOpenGraph->setPrefix('open-graph:'); @@ -90,7 +94,7 @@ public function it_can_set_and_render_prefix() } /** @test */ - public function it_can_set_and_render_type() + public function it_can_set_and_render_type(): void { $types = [ 'article', @@ -110,7 +114,7 @@ public function it_can_set_and_render_type() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; @@ -123,7 +127,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'Hello World detailed description.'; @@ -136,7 +140,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_url() + public function it_can_set_and_render_url(): void { $url = 'http://www.imdb.com/title/tt0080339/'; @@ -149,7 +153,7 @@ public function it_can_set_and_render_url() } /** @test */ - public function it_can_set_and_render_image() + public function it_can_set_and_render_image(): void { $image = 'http://ia.media-imdb.com/images/M/MV5BNDU2MjE4MTcwNl5BMl5BanBnXkFtZTgwNDExOTMxMDE@._V1_UY1200_CR90,0,630,1200_AL_.jpg'; @@ -162,7 +166,7 @@ public function it_can_set_and_render_image() } /** @test */ - public function it_can_set_and_render_site_name() + public function it_can_set_and_render_site_name(): void { $siteName = 'My site name'; @@ -175,7 +179,7 @@ public function it_can_set_and_render_site_name() } /** @test */ - public function it_can_add_and_render_property() + public function it_can_add_and_render_property(): void { $locales = [ 'ar', 'en', 'en_US', 'es', 'fr', 'fr_FR', @@ -192,7 +196,7 @@ public function it_can_add_and_render_property() } /** @test */ - public function it_can_add_render_properties() + public function it_can_add_render_properties(): void { $properties = [ 'locale' => 'en_GB', @@ -214,7 +218,7 @@ public function it_can_add_render_properties() } /** @test */ - public function it_can_enable_and_disable() + public function it_can_enable_and_disable(): void { static::assertTrue($this->seoOpenGraph->isEnabled()); static::assertFalse($this->seoOpenGraph->isDisabled()); @@ -234,7 +238,7 @@ public function it_can_enable_and_disable() } /** @test */ - public function it_can_set_and_render_locale_property() + public function it_can_set_and_render_locale_property(): void { $locales = ['fr_FR', 'en_GB', 'es_ES']; @@ -247,7 +251,7 @@ public function it_can_set_and_render_locale_property() } /** @test */ - public function it_can_set_and_render_alternative_properties() + public function it_can_set_and_render_alternative_properties(): void { $this->seoOpenGraph->setAlternativeLocales(['fr_FR', 'en_GB', 'es_ES']); diff --git a/tests/SeoTwitterTest.php b/tests/SeoTwitterTest.php index df61316..ba67e81 100644 --- a/tests/SeoTwitterTest.php +++ b/tests/SeoTwitterTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests; use Arcanedev\SeoHelper\SeoTwitter; @@ -44,7 +48,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_be_instantiated() + public function it_can_be_instantiated(): void { $expectations = [ \Arcanedev\SeoHelper\SeoTwitter::class, @@ -58,7 +62,7 @@ public function it_can_be_instantiated() } /** @test */ - public function it_can_render_defaults() + public function it_can_render_defaults(): void { $output = $this->seoTwitter->render(); @@ -74,7 +78,7 @@ public function it_can_render_defaults() } /** @test */ - public function it_can_set_and_render_type() + public function it_can_set_and_render_type(): void { $this->seoTwitter->setType('app'); @@ -85,7 +89,7 @@ public function it_can_set_and_render_type() } /** @test */ - public function it_can_set_and_render_site() + public function it_can_set_and_render_site(): void { $this->seoTwitter->setSite('Arcanedev'); @@ -96,7 +100,7 @@ public function it_can_set_and_render_site() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $this->seoTwitter->setTitle('ARCANEDEV super title'); @@ -107,7 +111,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $this->seoTwitter->setDescription('ARCANEDEV super description'); @@ -118,7 +122,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_add_and_render_image() + public function it_can_add_and_render_image(): void { $this->seoTwitter->addImage('http://example.com/img/avatar.png'); @@ -129,7 +133,7 @@ public function it_can_add_and_render_image() } /** @test */ - public function it_can_reset_card() + public function it_can_reset_card(): void { $expected = $this->seoTwitter->render(); @@ -146,7 +150,7 @@ public function it_can_reset_card() } /** @test */ - public function it_can_add_and_render_a_meta() + public function it_can_add_and_render_a_meta(): void { $this->seoTwitter->addMeta('creator', '@Arcanedev'); @@ -157,7 +161,7 @@ public function it_can_add_and_render_a_meta() } /** @test */ - public function it_can_add_and_render_many_metas() + public function it_can_add_and_render_many_metas(): void { $metas = [ 'creator' => '@Arcanedev', @@ -179,7 +183,7 @@ public function it_can_add_and_render_many_metas() } /** @test */ - public function it_can_enable_and_disable() + public function it_can_enable_and_disable(): void { static::assertTrue($this->seoTwitter->isEnabled()); static::assertFalse($this->seoTwitter->isDisabled()); diff --git a/tests/Stubs/Dummy.php b/tests/Stubs/Dummy.php index aa7fde0..fd6c50b 100644 --- a/tests/Stubs/Dummy.php +++ b/tests/Stubs/Dummy.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Stubs; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Stubs; use Arcanedev\SeoHelper\Traits\Seoable; diff --git a/tests/TestCase.php b/tests/TestCase.php index 13d314b..b10dab0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests; use Orchestra\Testbench\TestCase as BaseTestCase; @@ -36,33 +40,19 @@ public function setUp(): void * * @return array */ - protected function getPackageProviders($app) + protected function getPackageProviders($app): array { return [ \Arcanedev\SeoHelper\SeoHelperServiceProvider::class, ]; } - /** - * Get package aliases. - * - * @param \Illuminate\Foundation\Application $app - * - * @return array - */ - protected function getPackageAliases($app) - { - return [ - // - ]; - } - /** * Define environment setup. * * @param \Illuminate\Foundation\Application $app */ - protected function getEnvironmentSetUp($app) + protected function getEnvironmentSetUp($app): void { // Keywords $app['config']->set('seo-helper.keywords', [ @@ -94,7 +84,7 @@ protected function getEnvironmentSetUp($app) /** * Get Config instance. * - * @return \Illuminate\Config\Repository + * @return \Illuminate\Contracts\Config\Repository */ protected function config() { diff --git a/tests/Traits/SeoableTest.php b/tests/Traits/SeoableTest.php index 7e112ef..d37cd9f 100644 --- a/tests/Traits/SeoableTest.php +++ b/tests/Traits/SeoableTest.php @@ -1,4 +1,8 @@ -<?php namespace Arcanedev\SeoHelper\Tests\Traits; +<?php + +declare(strict_types=1); + +namespace Arcanedev\SeoHelper\Tests\Traits; use Arcanedev\SeoHelper\Tests\Stubs\Dummy; use Arcanedev\SeoHelper\Tests\TestCase; @@ -44,7 +48,7 @@ public function tearDown(): void */ /** @test */ - public function it_can_get_main_helper() + public function it_can_get_main_helper(): void { $seoHelper = $this->dummy->seo(); @@ -60,7 +64,7 @@ public function it_can_get_main_helper() } /** @test */ - public function it_can_get_meta_helper() + public function it_can_get_meta_helper(): void { $seoMeta = $this->dummy->seoMeta(); @@ -76,7 +80,7 @@ public function it_can_get_meta_helper() } /** @test */ - public function it_can_get_open_graph_helper() + public function it_can_get_open_graph_helper(): void { $seoOpenGraph = $this->dummy->seoGraph(); @@ -92,7 +96,7 @@ public function it_can_get_open_graph_helper() } /** @test */ - public function it_can_get_twitter_card_helper() + public function it_can_get_twitter_card_helper(): void { $seoTwitter = $this->dummy->seoCard(); $expectations = [ @@ -107,7 +111,7 @@ public function it_can_get_twitter_card_helper() } /** @test */ - public function it_can_set_and_render_title() + public function it_can_set_and_render_title(): void { $title = 'Hello World'; $siteName = 'ARCANEDEV'; @@ -130,7 +134,7 @@ public function it_can_set_and_render_title() } /** @test */ - public function it_can_set_and_render_description() + public function it_can_set_and_render_description(): void { $description = 'ARCANEDEV super description'; $expectations = [ @@ -151,7 +155,7 @@ public function it_can_set_and_render_description() } /** @test */ - public function it_can_set_and_render_keywords() + public function it_can_set_and_render_keywords(): void { $keywords = $this->getSeoHelperConfig('keywords.default'); $expected = '<meta name="keywords" content="'.implode(', ', $keywords).'">';