diff --git a/composer.json b/composer.json index 91e4d33..57c0555 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": ">=5.4" }, "require-dev": { - "phpunit/phpunit": "5.7.*" + "phpunit/phpunit": "4.8.*" }, "autoload": { "psr-4": { diff --git a/src/Eusonlito/LaravelMeta/FixesTrait.php b/src/Eusonlito/LaravelMeta/FixesTrait.php index a65acdb..4e373e5 100644 --- a/src/Eusonlito/LaravelMeta/FixesTrait.php +++ b/src/Eusonlito/LaravelMeta/FixesTrait.php @@ -7,7 +7,7 @@ trait FixesTrait * @param string $text * @return string */ - private function plain($text) + protected function plain($text) { return trim(str_replace('"', '"', preg_replace('/[\r\n\s]+/', ' ', strip_tags($text)))); } @@ -17,7 +17,7 @@ private function plain($text) * @param string $key * @return string */ - private function cut($text, $key) + protected function cut($text, $key) { if (empty($text) || !is_string($text)) { return $text; diff --git a/src/Eusonlito/LaravelMeta/Meta.php b/src/Eusonlito/LaravelMeta/Meta.php index 8fd13b2..f63326d 100644 --- a/src/Eusonlito/LaravelMeta/Meta.php +++ b/src/Eusonlito/LaravelMeta/Meta.php @@ -8,22 +8,22 @@ class Meta /** * @var array */ - private $config = []; + protected $config = []; /** * @var array */ - private $metas = []; + protected $metas = []; /** * @var string */ - private $title; + protected $title; /** * @var array */ - private $defaults = [ + protected $defaults = [ 'title_limit' => 70, 'description_limit' => 200, 'image_limit' => 5, @@ -33,10 +33,10 @@ class Meta /** * @var object; */ - private static $instance; + protected static $instance; /** - * @param array $config + * @param array $config = [] * @return object */ public static function getInstance(array $config = []) @@ -45,23 +45,21 @@ public static function getInstance(array $config = []) } /** - * @param array $config + * @param array $config = [] * * @return this */ public function __construct($config = []) { - if ($config) { + if (!empty($config)) { $this->setConfig($config); } $this->metas['image'] = []; - - return $this; } /** - * @param array $config + * @param array $config = [] * * @return this */ @@ -81,7 +79,7 @@ public function setConfig(array $config = []) } /** - * @param string $title + * @param string|null $title = null * * @return string */ @@ -133,7 +131,7 @@ public function remove($key) * * @return string */ - private function setTitle($value) + protected function setTitle($value) { $title = $this->title; @@ -152,10 +150,10 @@ private function setTitle($value) * * @return string */ - private function setImage($value) + protected function setImage($value) { if (count($this->metas['image']) >= $this->config['image_limit']) { - return; + return ''; } $this->metas['image'][] = $value; @@ -166,18 +164,18 @@ private function setImage($value) /** * @return void */ - private function removeImage() + protected function removeImage() { $this->metas['image'] = []; } /** * @param string $key - * @param string|array $default + * @param string|array $default = '' * - * @return string + * @return string|array */ - public function get($key, $default = null) + public function get($key, $default = '') { $method = 'get'.$key; @@ -195,7 +193,7 @@ public function get($key, $default = null) /** * @param string|array $default * - * @return string + * @return array */ public function getImage($default) { @@ -210,11 +208,11 @@ public function getImage($default) /** * @param string $key - * @param string|array $default + * @param string|array $default = '' * * @return string */ - public function tag($key, $default = null) + public function tag($key, $default = '') { if (!($values = $this->get($key, $default))) { return ''; @@ -238,7 +236,7 @@ public function tag($key, $default = null) } /** - * @param string $key + * @param array $keys = [] * * @return string */