<commit_before><?php

namespace Oxygen\Core\View;

use Illuminate\View\Factory as BaseFactory;
use Oxygen\Data\Behaviour\Timestamps;

class Factory extends BaseFactory {

    /**
     * Get the evaluated view contents for the given string.
     *
     * @param  string  $contents
     * @param  string  $unique
     * @param  int     $timestamp
     * @param  array   $data
     * @param  array   $mergeData
     * @return \Illuminate\View\View
     */
    public function string($contents, $unique, $timestamp, $data = [], $mergeData = []) {
        $data = array_merge($mergeData, $this->parseData($data));

        $this->callCreator($view = new StringView($this, $this->engines->resolve('blade.string'), $contents, $unique, $timestamp, $data));

        return $view;
    }

    /**
     * Get the evaluated view contents for the given model and field.
     * If the model doesn't use timestamps then the view will be re-compiled on every request.
     *
     * @param  object  $model
     * @param  string  $field
     * @param  array   $data
     * @param  array   $mergeData
     * @return \Illuminate\View\View
     */
    public function model($model, $field, $data = [], $mergeData = []) {
        $contents = $model->getAttribute($field);
        $path = $this->pathFromModel($model, $field);
        $timestamp = class_uses($model, Timestamps::class) ? $model->getAttribute('updatedAt')->getTimestamp() : 0;

        return $this->string($contents, $path, $timestamp, $data, $mergeData);
    }

    /**
     * Generates a unique path from a model.
     *
     * @param object $model
     * @param string $field
     * @return string
     */

    protected function pathFromModel($model, $field) {
        $path = 'db_' . get_class($model) . '_' . $model->getId() . '_' . $field;
        return strtolower(str_replace(['-', '.'], '_', $path));
    }

}<commit_msg>Added external interface for `pathFromModel` inside the view factory, and tightened constraints<commit_after><?php

namespace Oxygen\Core\View;

use Illuminate\View\Factory as BaseFactory;
use Oxygen\Data\Behaviour\PrimaryKey;
use Oxygen\Data\Behaviour\Timestamps;

class Factory extends BaseFactory {

    /**
     * Get the evaluated view contents for the given string.
     *
     * @param  string  $contents
     * @param  string  $unique
     * @param  int     $timestamp
     * @param  array   $data
     * @param  array   $mergeData
     * @return \Illuminate\View\View
     */
    public function string($contents, $unique, $timestamp, $data = [], $mergeData = []) {
        $data = array_merge($mergeData, $this->parseData($data));

        $this->callCreator($view = new StringView($this, $this->engines->resolve('blade.string'), $contents, $unique, $timestamp, $data));

        return $view;
    }

    /**
     * Get the evaluated view contents for the given model and field.
     * If the model doesn't use timestamps then the view will be re-compiled on every request.
     *
     * @param  PrimaryKey  $model
     * @param  string  $field
     * @param  array   $data
     * @param  array   $mergeData
     * @return \Illuminate\View\View
     */
    public function model(PrimaryKey $model, $field, $data = [], $mergeData = []) {
        $contents = $model->getAttribute($field);
        $path = $this->pathFromModel(get_class($model), $model->getId(), $field);
        $timestamp = class_uses($model, Timestamps::class) ? $model->getAttribute('updatedAt')->getTimestamp() : 0;

        return $this->string($contents, $path, $timestamp, $data, $mergeData);
    }

    /**
     * Generates a unique path from a model.
     *
     * @param        $className
     * @param        $id
     * @param string $field
     * @return string
     */
    public function pathFromModel($className, $id, $field) {
        $path = 'db_' . $className . '_' . $id . '_' . $field;
        return strtolower(str_replace(['-', '.'], '_', $path));
    }

}
{'fraction_non_alphanumeric': 0.1446028513238289, 'fraction_numerical': 0.0005091649694501018, 'mean_word_length': 2.6857410881801127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '7109486', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1181, 'n_words': 313}