This commit is contained in:
TomasVotruba 2017-09-07 00:32:57 +02:00
parent 08600382c2
commit 3b2976f849

View File

@ -66,22 +66,30 @@ final class TriggerMessageResolver
$words = explode(' ', $message);
foreach ($words as $word) {
// is method()
if (Strings::endsWith($word, '()') && strlen($word) > 2) {
// doesn't include class in the beggning
if (! Strings::startsWith($word, $class)) {
$word = $class . '::' . $word;
}
// is method('...')
} elseif (Strings::endsWith($word,'\')')) {
if (! Strings::startsWith($word, $class)) {
$word = $class . '::' . $word;
}
}
$completeMessage .= ' ' . $word;
$completeMessage .= ' ' . $this->prependClassToMethodCallIfNeeded($word, $class);
}
return trim($completeMessage);
}
private function prependClassToMethodCallIfNeeded(string $word, string $class): string
{
// is method()
if (Strings::endsWith($word, '()') && strlen($word) > 2) {
// doesn't include class in the beggning
if (! Strings::startsWith($word, $class)) {
return $class . '::' . $word;
}
}
// is method('...')
if (Strings::endsWith($word, '\')')) {
// doesn't include class in the beggning
if (! Strings::startsWith($word, $class)) {
return $class . '::' . $word;
}
}
return $word;
}
}