<commit_before><?php

namespace BoomCMS\Core\Page;

use Boom\Model\Page as Model;
use Boom\Page\Finder;

class Provider
{
    public function findById($id)
    {
        return $this->findAndCache(Model::find($id));
    }

    public function findByInternalName($name)
    {
        return $this->findAndCache(Model::where('internal_name', '=', $name)->get());
    }

    public function findByPrimaryUri($uri)
    {
        return $this->findAndCache(Model::where('primary_uri', '=', $uri)->get());
    }

    public function findByUri($uri)
    {
        $finder = new Finder();
        $finder->addFilter(new Finder\Filter\Uri($uri));

        return $this->findAndCache($finder->find());
    }

    private function findAndCache(Model $model)
    {
        if ($model->id) {
            $this->cache[$model->id] = $model;
        }

        return new Page($model->toArray());
    }

    public function save(Page $page)
    {

    }
}
<commit_msg>Added TODO comment to page provider<commit_after><?php

namespace BoomCMS\Core\Page;

use Boom\Model\Page as Model;
use Boom\Page\Finder;

/**
 * TODO: Need to not return deleted / invisible pages by default with option to show a hidden page.
 *
 * This should probably be done by providing an editor instance to the consuctor
 * with a boolean flag to change whether hidden pages are returned.
 *
 */

class Provider
{
    public function findById($id)
    {
        return $this->findAndCache(Model::find($id));
    }

    public function findByInternalName($name)
    {
        return $this->findAndCache(Model::where('internal_name', '=', $name)->get());
    }

    public function findByPrimaryUri($uri)
    {
        return $this->findAndCache(Model::where('primary_uri', '=', $uri)->get());
    }

    public function findByUri($uri)
    {
        $finder = new Finder();
        $finder->addFilter(new Finder\Filter\Uri($uri));

        return $this->findAndCache($finder->find());
    }

    private function findAndCache(Model $model)
    {
        if ($model->id) {
            $this->cache[$model->id] = $model;
        }

        return new Page($model->toArray());
    }

    public function save(Page $page)
    {

    }
}

{'fraction_non_alphanumeric': 0.14703196347031963, 'fraction_numerical': 0.0, 'mean_word_length': 2.7325383304940374, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4606857', 'n_tokens_mistral': 680, 'n_tokens_neox': 663, 'n_words': 152}