PHP code example of yab / cerebrum

1. Go to this page and download the library: Download yab/cerebrum 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/ */

    

yab / cerebrum example snippets


composer create-project laravel/lumen your-project-name

composer 

Yab\Cerebrum\CerebrumProvider::class

use Yab\Cerebrum\Memory;

class TaskService
{
    use Memory;

    public function __construct(TaskRespository $taskRepository)
    {
        $this->repository = $taskRepository;
        // provided by Memory
        $this->memoryDuration(15);
        $this->forgetful([
            'all'
        ]);
    }

    public function all()
    {
        return $this->remember($this->repository->all());
    }

    public function findById($id)
    {
        return $this->remember($this->repository->findById($id));
    }

    public function findByIdWithLongerCache($id)
    {
        return $this->remember($this->repository->findById($id), 1440);
    }

    public function update($id, $data)
    {
        $this->forget($id);
        return $this->repository->update($id, $data);
    }
}

use Yab\Cerebrum\Linguistics;

class TaskService
{
    use Linguistics;

    public function __construct(TaskRespository $taskRepository)
    {
        $this->repository = $taskRepository;
    }

    public function getKeyWords($id)
    {
        return $this->getKeyWords($this->repository->findById($id)->text);
    }

    public function search($searchString)
    {
        if ($this->isQuestion($seachString)) {
            return $this->repository->search();
        }
    }
}