echo LanguageDetector::detect(
'My tailor is rich and Alison is in the kitchen with Bob.',
['en', 'de', 'fr', 'es']
);
PHP Fatal error: Uncaught Error: Call to a member function getLanguages() on null in PATH/LanguageDetector/LanguageDetector.php:104
Stack trace:
#0 PATH(31): LanguageDetector\LanguageDetector::detect('My tailor is ri...', Array)
public static function detect($text, array $languages = []): self
{
// All specified models have been loaded
$diff = count($languages)
? array_diff(
self::$detector->getLanguages(),
$languages
)
: [];
if (is_null(self::$detector) || count($diff)) {
self::$detector = new self(null, $languages);
}
return self::$detector->evaluate($text);
}
Error on line self::$detector->getLanguages(),
Maybe before need to add:
if (is_null(self::$detector)) {
self::$detector = new self(null, $languages);
}
Code from README.md
Error on line
self::$detector->getLanguages(),
Maybe before need to add: