Completed
Push — master ( 1337ee...b15437 )
by Wanderson
01:57
created

Keywords::toKeys()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 6
rs 9.4285
c 1
b 0
f 1
1
<?php
2
3
namespace Win\Html\Seo;
4
5
use Win\Mvc\Application;
6
use function strLower;
7
use function strTruncate;
8
9
/**
10
 * Auxilia gerenciamento de keywords
11
 */
12
class Keywords {
13
14
	const MAX_LENGTH = 100;
15
16
	/**
17
	 * Retorna uma string em minuscula, separada por virgula
18
	 * @param string[]
19
	 */
20
	static function toKeys($array1, $array2 = []) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
		if (empty($array2)) {
22
			$array2 = [Application::app()->controller->getData('keywords')];
0 ignored issues
show
Documentation Bug introduced by
The method getData does not exist on object<Win\Mvc\Controller>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
23
		}
24
		return strLower(str_replace([',...', '...'], '', strTruncate(implode(', ', array_filter(array_merge($array1, $array2))), static::MAX_LENGTH)));
25
	}
26
27
}
28