<commit_before><?php

namespace Harp\MP;

use Harp\Harp\AbstractModel;
use Harp\Harp\Repo;
use Harp\Core\Model\Models;
use Harp\Core\Repo\AbstractLink;

/**
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014, Clippings Ltd.
 * @license   http://spdx.org/licenses/BSD-3-Clause
 */
trait MaterializedPathTrait
{
    public static function initialize(Repo $repo)
    {
        return $repo
            ->addRel(new BelongsTo('parent', $repo, $repo))
            ->addRel(new HasMany('children', $repo, $repo, ['foreignKey' => 'parentId']));
    }

    public $path;
    public $parentId;

    /**
     * @param  string $name
     * @return AbstractLink
     */
    abstract public function getLink($name);

    abstract public function getId();

    /**
     * @return AbstractModel
     */
    public function getParent()
    {
        return $this->get('parent');
    }

    /**
     * @param  AbstractModel $model
     * @return AbstractModel $this
     */
    public function setParent(AbstractModel $model)
    {
        static::getRepo()->assertModel($model);

        $this->set('parent', $model);

        return $this;
    }

    /**
     * @return \Harp\Core\Repo\LinkMany
     */
    public function getChildren()
    {
        return $this->all('children');<commit_msg>Add some constraints to trait<commit_after><?php

namespace Harp\MP;

use Harp\Harp\AbstractModel;
use Harp\Harp\Repo;
use Harp\Core\Model\Models;
use Harp\Core\Repo\AbstractLink;

/**
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014, Clippings Ltd.
 * @license   http://spdx.org/licenses/BSD-3-Clause
 */
trait MaterializedPathTrait
{
    public static function initialize(Repo $repo)
    {
        return $repo
            ->addRel(new BelongsTo('parent', $repo, $repo))
            ->addRel(new HasMany('children', $repo, $repo, ['foreignKey' => 'parentId']));
    }

    public $path;
    public $parentId;

    /**
     * @param  string $name
     * @return AbstractLink
     */
    abstract public function getLink($name);

    abstract public function getId();

    /**
     * @param  string $name
     * @return AbstractModel
     */
    abstract public function get($name);

    /**
     * @param  string $name
     * @return \Harp\Core\Models\AbstractModel
     */
    abstract public function set($name, \Harp\Core\Models\AbstractModel $Model);

    /**
     * @param  string $name
     * @return \Harp\Core\Repo\LinkMany
     */
    abstract public function all($name);

    /**
     * @return AbstractModel
     */
    public function getParent()
    {
        return $this->get('parent');
    }

    /**
     * @param  AbstractModel $model
     * @return AbstractModel $this
     */
    public function setParent(AbstractModel $model)
    {
        static::getRepo()->assertModel($model);

        $this->set('parent', $model);

        return $this;
    }

    /**
     * @return \Harp\Core\Repo\LinkMany
     */
    public function getChildren()
    {
        return $this->all('children');
{'fraction_non_alphanumeric': 0.14544235924932977, 'fraction_numerical': 0.003351206434316354, 'mean_word_length': 2.388195232690125, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5499615', 'n_tokens_mistral': 938, 'n_tokens_neox': 921, 'n_words': 202}