diff --git a/.gitignore b/.gitignore index 5826402..9c10d38 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.phar composer.lock .DS_Store +.idea diff --git a/README.md b/README.md index 63b6149..78e4bfb 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,12 @@ With this package you can manage header Meta Tags from Laravel controllers. ## Installation -- [Laravel MetaTags on Packagist](https://packagist.org/packages/torann/laravel-meta-tags) -- [Laravel MetaTags on GitHub](https://github.com/Torann/laravel-meta-tags) +- [Laravel MetaTags on Packagist](https://packagist.org/packages/provision/meta-tags) From the command line run ``` -$ composer require torann/laravel-meta-tags +$ composer require provision/meta-tags ``` Once Meta Tags is installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key. @@ -22,7 +21,7 @@ Once Meta Tags is installed you need to register the service provider with the a ```php 'providers' => array( - Torann\LaravelMetaTags\MetaTagsServiceProvider::class, + ProVision\MetaTags\MetaTagsServiceProvider::class, ) ``` @@ -32,7 +31,7 @@ Meta Tags also ships with a facade which provides the static syntax for creating ```php 'aliases' => array( - 'MetaTag' => Torann\LaravelMetaTags\Facades\MetaTag::class, + 'MetaTag' => ProVision\MetaTags\Facades\MetaTag::class, ) ``` @@ -42,7 +41,7 @@ Meta Tags also ships with a facade which provides the static syntax for creating Run this on the command line from the root of your project: ``` -$ php artisan vendor:publish --provider="Torann\LaravelMetaTags\MetaTagsServiceProvider" +$ php artisan vendor:publish --provider="ProVision\MetaTags\MetaTagsServiceProvider" ``` A configuration file will be publish to `config/meta-tags.php`. @@ -162,4 +161,4 @@ class HomeController extends Controller @yield('content') -``` \ No newline at end of file +``` diff --git a/composer.json b/composer.json index a3772ac..df2ce70 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,21 @@ { - "name": "torann/laravel-meta-tags", + "name": "provision/meta-tags", "keywords": ["meta tags", "meta", "tags", "head", "laravel"], "description": "A package to manage Header Meta Tags", "license": "MIT", "authors": [ { - "name": "Lito", - "email": "lito@eordes.com" - }, - { - "name": "Daniel Stainback", - "email": "daniel@lyften.com" + "name": "Venelin Iliev", + "email": "venelin@provision.bg" } ], "require": { "php": ">=5.5.9", - "illuminate/support": "5.1.*|5.2.*" - }, - "require-dev": { - "phpunit/phpunit": "^4.8", - "mockery/mockery": "^0.9.4" + "illuminate/support": "~5" }, "autoload": { "psr-4": { - "Torann\\LaravelMetaTags\\": "src/Torann/LaravelMetaTags/" + "ProVision\\MetaTags\\": "src/" } } } diff --git a/src/config/config.php b/config/config.php similarity index 100% rename from src/config/config.php rename to config/config.php diff --git a/src/Torann/LaravelMetaTags/Facades/MetaTag.php b/src/Facades/MetaTag.php similarity index 86% rename from src/Torann/LaravelMetaTags/Facades/MetaTag.php rename to src/Facades/MetaTag.php index fadf107..69f83d0 100644 --- a/src/Torann/LaravelMetaTags/Facades/MetaTag.php +++ b/src/Facades/MetaTag.php @@ -1,6 +1,6 @@ config['title_limit']) { $title = ' - '.$title; - $limit = $this->config['title_limit'] - strlen($title); + $limit = $this->config['title_limit'] - mb_strlen($title); } else { $limit = 'title'; @@ -265,7 +265,7 @@ private function createTag(array $values) $attributes = implode(' ', $attributes); - return "\n "; + return ""; } /** @@ -297,16 +297,16 @@ private function cut($text, $key) return $text; } - $length = strlen($text); + $length = mb_strlen($text); if ($length <= (int) $limit) { return $text; } - $text = substr($text, 0, ($limit -= 3)); + $text = mb_substr($text, 0, ($limit -= 3)); - if ($space = strrpos($text, ' ')) { - $text = substr($text, 0, $space); + if ($space = mb_strrpos($text, ' ')) { + $text = mb_substr($text, 0, $space); } return $text.'...'; diff --git a/src/Torann/LaravelMetaTags/MetaTagsServiceProvider.php b/src/MetaTagsServiceProvider.php similarity index 82% rename from src/Torann/LaravelMetaTags/MetaTagsServiceProvider.php rename to src/MetaTagsServiceProvider.php index 10e2028..4556c31 100644 --- a/src/Torann/LaravelMetaTags/MetaTagsServiceProvider.php +++ b/src/MetaTagsServiceProvider.php @@ -1,6 +1,6 @@ publishes([ - __DIR__.'/../../config/config.php' => config_path('meta-tags.php') + __DIR__ . '/../config/config.php' => config_path('meta-tags.php') ]); } @@ -32,7 +32,7 @@ public function boot() */ public function register() { - $this->app['metatag'] = $this->app->share(function ($app) { + $this->app->singleton('metatag', function ($app) { return new MetaTag( $app['request'], $app['config']['meta-tags'], diff --git a/tests/Tests.php b/tests/Tests.php index 05c7ac0..4aaf45c 100644 --- a/tests/Tests.php +++ b/tests/Tests.php @@ -22,11 +22,11 @@ protected static function text($length) $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $text = ''; - while (strlen($text) < $length) { + while (mb_strlen($text) < $length) { $text .= str_shuffle($base); } - return substr($text, 0, $length); + return mb_substr($text, 0, $length); } public function testMetaTitle() @@ -38,7 +38,7 @@ public function testMetaTitle() $response = $this->Meta->meta('title', $text = self::text(80)); $this->assertNotTrue($text, $response); - $this->assertTrue(strlen($response) === 70); + $this->assertTrue(mb_strlen($response) === 70); } public function testMetaDescription() @@ -50,7 +50,7 @@ public function testMetaDescription() $response = $this->Meta->meta('description', $text = self::text(250)); $this->assertNotTrue($text === $response); - $this->assertTrue(strlen($response) === 200); + $this->assertTrue(mb_strlen($response) === 200); } public function testMetaTitleWithTitle() @@ -66,7 +66,7 @@ public function testMetaTitleWithTitle() $response = $this->Meta->meta('title', $text = self::text(80)); $this->assertNotTrue($text.' - '.self::$title === $response); - $this->assertTrue(strlen($response) === 70); + $this->assertTrue(mb_strlen($response) === 70); } public function testMetaImage() @@ -99,8 +99,8 @@ public function testTagTitle() $tag = $this->Meta->tag('title'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'title"') === 4); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'title"') === 4); $this->assertTrue(strstr($tag, self::$title) ? true : false); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -112,8 +112,8 @@ public function testTagMetaNameTitle() $tag = $this->Meta->tagMetaName('title'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'title"') === 2); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'title"') === 2); $this->assertTrue(strstr($tag, self::$title) ? true : false); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -125,8 +125,8 @@ public function testTagMetaPropertyTitle() $tag = $this->Meta->tagMetaProperty('title'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'title"') === 2); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'title"') === 2); $this->assertTrue(strstr($tag, self::$title) ? true : false); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -137,8 +137,8 @@ public function testTagDescription() $tag = $this->Meta->tag('description'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'description"') === 4); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'description"') === 4); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -148,8 +148,8 @@ public function testTagMetaNameDescription() $tag = $this->Meta->tagMetaName('description'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'description"') === 2); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'description"') === 2); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -159,8 +159,8 @@ public function testTagMetaPropertyDescription() $tag = $this->Meta->tagMetaProperty('description'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'description"') === 2); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'description"') === 2); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -170,8 +170,8 @@ public function testTagKeywords() $tag = $this->Meta->tag('keywords'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'keywords"') === 2); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'keywords"') === 2); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -181,8 +181,8 @@ public function testTagMetaNameKeywords() $tag = $this->Meta->tagMetaName('keywords'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'keywords"') === 1); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'keywords"') === 1); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -192,8 +192,8 @@ public function testTagMetaPropertyKeywords() $tag = $this->Meta->tagMetaProperty('keywords'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'keywords"') === 1); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'keywords"') === 1); $this->assertTrue(strstr($tag, $text) ? true : false); } @@ -205,8 +205,8 @@ public function testTagImage() $tag = $this->Meta->tag('image'); - $this->assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'assertTrue(substr_count($tag, 'image') === 25); + $this->assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'assertTrue(mb_substr_count($tag, 'image') === 25); } }