Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mb_* #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.phar
composer.lock
.DS_Store
.idea
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ 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.

```php
'providers' => array(

Torann\LaravelMetaTags\MetaTagsServiceProvider::class,
ProVision\MetaTags\MetaTagsServiceProvider::class,

)
```
Expand All @@ -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,

)
```
Expand All @@ -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`.
Expand Down Expand Up @@ -162,4 +161,4 @@ class HomeController extends Controller
@yield('content')
</body>
</html>
```
```
18 changes: 5 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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/"
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Torann\LaravelMetaTags\Facades;
namespace ProVision\MetaTags\Facades;

use Illuminate\Support\Facades\Facade;

Expand Down
14 changes: 7 additions & 7 deletions src/Torann/LaravelMetaTags/MetaTag.php → src/MetaTag.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Torann\LaravelMetaTags;
namespace ProVision\MetaTags;

use Illuminate\Http\Request;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -241,7 +241,7 @@ private function setTitle($value)

if ($title && $this->config['title_limit']) {
$title = ' - '.$title;
$limit = $this->config['title_limit'] - strlen($title);
$limit = $this->config['title_limit'] - mb_strlen($title);
}
else {
$limit = 'title';
Expand All @@ -265,7 +265,7 @@ private function createTag(array $values)

$attributes = implode(' ', $attributes);

return "<meta {$attributes}>\n ";
return "<meta {$attributes}>";
}

/**
Expand Down Expand Up @@ -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.'...';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Torann\LaravelMetaTags;
namespace ProVision\MetaTags;

use Illuminate\Support\ServiceProvider;

Expand All @@ -21,7 +21,7 @@ class MetaTagsServiceProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__.'/../../config/config.php' => config_path('meta-tags.php')
__DIR__ . '/../config/config.php' => config_path('meta-tags.php')
]);
}

Expand All @@ -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'],
Expand Down
52 changes: 26 additions & 26 deletions tests/Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -99,8 +99,8 @@ public function testTagTitle()

$tag = $this->Meta->tag('title');

$this->assertTrue(substr_count($tag, '<meta') === 4);
$this->assertTrue(substr_count($tag, 'title"') === 4);
$this->assertTrue(mb_substr_count($tag, '<meta') === 4);
$this->assertTrue(mb_substr_count($tag, 'title"') === 4);
$this->assertTrue(strstr($tag, self::$title) ? true : false);
$this->assertTrue(strstr($tag, $text) ? true : false);
}
Expand All @@ -112,8 +112,8 @@ public function testTagMetaNameTitle()

$tag = $this->Meta->tagMetaName('title');

$this->assertTrue(substr_count($tag, '<meta') === 2);
$this->assertTrue(substr_count($tag, 'title"') === 2);
$this->assertTrue(mb_substr_count($tag, '<meta') === 2);
$this->assertTrue(mb_substr_count($tag, 'title"') === 2);
$this->assertTrue(strstr($tag, self::$title) ? true : false);
$this->assertTrue(strstr($tag, $text) ? true : false);
}
Expand All @@ -125,8 +125,8 @@ public function testTagMetaPropertyTitle()

$tag = $this->Meta->tagMetaProperty('title');

$this->assertTrue(substr_count($tag, '<meta') === 2);
$this->assertTrue(substr_count($tag, 'title"') === 2);
$this->assertTrue(mb_substr_count($tag, '<meta') === 2);
$this->assertTrue(mb_substr_count($tag, 'title"') === 2);
$this->assertTrue(strstr($tag, self::$title) ? true : false);
$this->assertTrue(strstr($tag, $text) ? true : false);
}
Expand All @@ -137,8 +137,8 @@ public function testTagDescription()

$tag = $this->Meta->tag('description');

$this->assertTrue(substr_count($tag, '<meta') === 4);
$this->assertTrue(substr_count($tag, 'description"') === 4);
$this->assertTrue(mb_substr_count($tag, '<meta') === 4);
$this->assertTrue(mb_substr_count($tag, 'description"') === 4);
$this->assertTrue(strstr($tag, $text) ? true : false);
}

Expand All @@ -148,8 +148,8 @@ public function testTagMetaNameDescription()

$tag = $this->Meta->tagMetaName('description');

$this->assertTrue(substr_count($tag, '<meta') === 2);
$this->assertTrue(substr_count($tag, 'description"') === 2);
$this->assertTrue(mb_substr_count($tag, '<meta') === 2);
$this->assertTrue(mb_substr_count($tag, 'description"') === 2);
$this->assertTrue(strstr($tag, $text) ? true : false);
}

Expand All @@ -159,8 +159,8 @@ public function testTagMetaPropertyDescription()

$tag = $this->Meta->tagMetaProperty('description');

$this->assertTrue(substr_count($tag, '<meta') === 2);
$this->assertTrue(substr_count($tag, 'description"') === 2);
$this->assertTrue(mb_substr_count($tag, '<meta') === 2);
$this->assertTrue(mb_substr_count($tag, 'description"') === 2);
$this->assertTrue(strstr($tag, $text) ? true : false);
}

Expand All @@ -170,8 +170,8 @@ public function testTagKeywords()

$tag = $this->Meta->tag('keywords');

$this->assertTrue(substr_count($tag, '<meta') === 2);
$this->assertTrue(substr_count($tag, 'keywords"') === 2);
$this->assertTrue(mb_substr_count($tag, '<meta') === 2);
$this->assertTrue(mb_substr_count($tag, 'keywords"') === 2);
$this->assertTrue(strstr($tag, $text) ? true : false);
}

Expand All @@ -181,8 +181,8 @@ public function testTagMetaNameKeywords()

$tag = $this->Meta->tagMetaName('keywords');

$this->assertTrue(substr_count($tag, '<meta') === 1);
$this->assertTrue(substr_count($tag, 'keywords"') === 1);
$this->assertTrue(mb_substr_count($tag, '<meta') === 1);
$this->assertTrue(mb_substr_count($tag, 'keywords"') === 1);
$this->assertTrue(strstr($tag, $text) ? true : false);
}

Expand All @@ -192,8 +192,8 @@ public function testTagMetaPropertyKeywords()

$tag = $this->Meta->tagMetaProperty('keywords');

$this->assertTrue(substr_count($tag, '<meta') === 1);
$this->assertTrue(substr_count($tag, 'keywords"') === 1);
$this->assertTrue(mb_substr_count($tag, '<meta') === 1);
$this->assertTrue(mb_substr_count($tag, 'keywords"') === 1);
$this->assertTrue(strstr($tag, $text) ? true : false);
}

Expand All @@ -205,8 +205,8 @@ public function testTagImage()

$tag = $this->Meta->tag('image');

$this->assertTrue(substr_count($tag, '<meta') === 20);
$this->assertTrue(substr_count($tag, '<link') === 5);
$this->assertTrue(substr_count($tag, 'image') === 25);
$this->assertTrue(mb_substr_count($tag, '<meta') === 20);
$this->assertTrue(mb_substr_count($tag, '<link') === 5);
$this->assertTrue(mb_substr_count($tag, 'image') === 25);
}
}