add getStringValue() to value resolver (#1130)

This commit is contained in:
Tomas Votruba 2021-11-02 15:40:12 +01:00 committed by GitHub
parent f6afff9f24
commit 29b79786e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,16 @@ final class ValueResolver
return $this->getValue($expr) === $value;
}
public function getStringValue(Expr $expr): string
{
$resolvedValue = $this->getValue($expr);
if (! is_string($resolvedValue)) {
throw new ShouldNotHappenException();
}
return $resolvedValue;
}
/**
* @return mixed|null
*/