<commit_before><?php namespace TypiCMS\Presenters;

use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;

class Presenter {


	/**
	* Return an instance of a Model wrapped
	* in a presenter object
	*
	* @param Model $model
	* @param Presentable $presenter
	* @return Model
	*/
	// public function model(Model $model, Presentable $presenter)
	public function model($model, Presentable $presenter)
	{
		$object = clone $presenter;

		$object->set($model);

		return $object;
	}


	/**
	* Return an instance of a Collection with each value
	* wrapped in a presenter object
	*
	* @param Collection $collection
	* @param Presentable $presenter
	* @return Collection
	*/
	public function collection(Collection $collection, Presentable $presenter)
	{
		foreach($collection as $key => $value) {
			$collection->put($key, $this->model($value, $presenter));
		}

		return $collection;
	}


	/**
	* Return an instance of a Paginator with each value
	* wrapped in a presenter object
	*
	* @param Paginator $paginator
	* @param Presentable $presenter
	* @return Paginator
	*/
	public function paginator(Paginator $paginator, Presentable $presenter)
	{
		$items = array();

		foreach($paginator->getItems() as $item) {
			$items[] = $this->model($item, $presenter);
		}

		$paginator->setItems($items);
<commit_msg>presenter for nested collection<commit_after><?php namespace TypiCMS\Presenters;

use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;

class Presenter {


	/**
	* Return an instance of a Model wrapped
	* in a presenter object
	*
	* @param Model $model
	* @param Presentable $presenter
	* @return Model
	*/
	// public function model(Model $model, Presentable $presenter)
	public function model($model, Presentable $presenter)
	{
		$object = clone $presenter;

		$object->set($model);

		return $object;
	}


	/**
	* Return an instance of a Collection with each value
	* wrapped in a presenter object
	*
	* @param Collection $collection
	* @param Presentable $presenter
	* @return Collection
	*/
	public function collection(Collection $collection, Presentable $presenter)
	{
		foreach($collection as $key => $value) {
			$collection->put($key, $this->model($value, $presenter));
			if ($value->children instanceof Collection) {
				$this->collection($value->children, $presenter);
			}
		}

		return $collection;
	}


	/**
	* Return an instance of a Paginator with each value
	* wrapped in a presenter object
	*
	* @param Paginator $paginator
	* @param Presentable $presenter
	* @return Paginator
	*/
	public function paginator(Paginator $paginator, Presentable $presenter)
	{
		$items = array();

		foreach($paginator->getItems() as $item) {
			$items[] = $this->model($item, $presenter);
		}

		$paginator->setItems($items);

{'fraction_non_alphanumeric': 0.1251356238698011, 'fraction_numerical': 0.0, 'mean_word_length': 4.288718929254302, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '111526', 'n_tokens_mistral': 913, 'n_tokens_neox': 863, 'n_words': 247}