public function testExecute() { $instance = new Decomposer(); $this->assertEquals('ㄱㅏㄴㅏㄷㅏ', $instance->execute('가나다')); $this->assertEquals('ㄱㅏabㄴㅏcㄷㅏde', $instance->execute('가ab나c다de')); $this->assertEquals('aㄱㅏㄴㅏ bcㄷㅏ de', $instance->execute('a가나 bc다 de')); }
/** * Search similar tags by given string * * @param string $string partial of word * @param int $take take count * @param string|null $instanceId instance id of taggable * @return Collection|static[] */ public function similar($string, $take = 15, $instanceId = null) { $model = $this->createModel(); $query = $model->newQuery()->where('decomposed', 'like', $this->decomposer->execute($string) . '%')->orderBy('count', 'desc')->take($take); if ($instanceId) { $query->where('instanceId', $instanceId); } return $query->get(); }