Various code cleanup.

This commit is contained in:
James Cole
2018-07-27 05:03:37 +02:00
parent 0312ba8ad7
commit e3e0e12fef
43 changed files with 167 additions and 145 deletions

View File

@@ -101,6 +101,8 @@ class Modifier
try {
$compareDate = new Carbon($compare);
} catch (Exception $e) {
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
return false;
}
@@ -118,6 +120,8 @@ class Modifier
try {
$compareDate = new Carbon($compare);
} catch (Exception $e) {
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
return false;
}
@@ -135,6 +139,8 @@ class Modifier
try {
$compareDate = new Carbon($compare);
} catch (Exception $e) {
Log::debug(sprintf('Not interesting: %s', $e->getMessage()));
return false;
}

View File

@@ -63,7 +63,7 @@ class Search implements SearchInterface
public function getWordsAsString(): string
{
$string = implode(' ', $this->words);
if (0 === \strlen($string)) {
if ('' === $string) {
return \is_string($this->originalQuery) ? $this->originalQuery : '';
}
@@ -81,7 +81,7 @@ class Search implements SearchInterface
/**
* @param string $query
*/
public function parseQuery(string $query)
public function parseQuery(string $query): void
{
$filteredQuery = $query;
$this->originalQuery = $query;
@@ -171,7 +171,7 @@ class Search implements SearchInterface
/**
* @param int $limit
*/
public function setLimit(int $limit)
public function setLimit(int $limit): void
{
$this->limit = $limit;
}
@@ -179,7 +179,7 @@ class Search implements SearchInterface
/**
* @param User $user
*/
public function setUser(User $user)
public function setUser(User $user): void
{
$this->user = $user;
}
@@ -242,13 +242,13 @@ class Search implements SearchInterface
/**
* @param string $string
*/
private function extractModifier(string $string)
private function extractModifier(string $string): void
{
$parts = explode(':', $string);
if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && \strlen(trim((string)$parts[1]))) {
if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && '' !== trim((string)$parts[1])) {
$type = trim((string)$parts[0]);
$value = trim((string)$parts[1]);
if (\in_array($type, $this->validModifiers)) {
if (\in_array($type, $this->validModifiers, true)) {
// filter for valid type
$this->modifiers->push(['type' => $type, 'value' => $value]);
}
@@ -292,9 +292,9 @@ class Search implements SearchInterface
*
* @return bool
*/
private function strposArray(string $haystack, array $needle)
private function strposArray(string $haystack, array $needle): bool
{
if (0 === \strlen($haystack)) {
if ('' === $haystack) {
return false;
}
foreach ($needle as $what) {