1. Go to this page and download the library: Download celestial/lexicology library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Celestial\Lexicology\Suggestion;
$suggestion = new Suggestion();
$suggestions = $suggestion->getSingleSuggestion('string',[], null, 'meta');
print_r($suggestions);
// ['meta']
use Celestial\Lexicology\Method\AbstractMethod;
use Celestial\Lexicology\Method\Interfaces\FilterInterface;
use Celestial\Lexicology\Method\Interfaces\SortInterface;
class CustomMethod extends AbstractMethod implements SortInterface, FilterInterface
{
use \Celestial\Lexicology\Method\Traits\SortTrait;
/**
* Return a sort value if either a or b match.
*
* @inheritdoc
*/
public function sortPair($a, $b) {
if ($a === $b) {
return 0;
} elseif ($a === $this->getField()) {
return 1;
} elseif ($b === $this->getField()) {
return -1;
}
return null;
}
/**
* Return a filter array of string that have more than 5 characters
*
* @inheritdoc
*/
public function filter($possibleValues) {
return array_values(array_filter($possibleValues, function($value){
return (strlen($value) > 5);
}));
}
}