<commit_before><?php
namespace Core42\View\Helper;

use Zend\View\Helper\AbstractHelper;

class ValueManager extends AbstractHelper
{
    /**
     * @var \Core42\ValueManager\ValueManager
     */
    private $valueManager;

    /**
     * @var string
     */
    private $errorPartial;

    /**
     * @return \Core42\View\Helper\ValueManager
     */
    public function __invoke()
    {
        return $this;
    }

    /**
     * @param  \Core42\ValueManager\ValueManager $valueManager
     * @return \Core42\View\Helper\ValueManager
     */
    public function setValueManager(\Core42\ValueManager\ValueManager $valueManager)
    {
        $this->valueManager = $valueManager;

        return $this;
    }

    /**
     * @param $partial
     * @return \Core42\View\Helper\InputManager
     */
    public function setErrorPartial($partial)
    {
        $this->errorPartial = $partial;

        return $this;
    }

    /**
     * @param  string $name
     * @return string
     */
    public function renderError($name = null)
    {
        $partialHelper = $this->view->plugin('partial');

        $model = array(
            'valueManager' => $this->valueManager,
            'errorMessages' => $this->valueManager->getErrors($name),
        );

        return $partialHelper($this->errorPartial, $model);
    }

    /**
     * @param  string     $name
     * @param  bool       $escape
     * @return array|null
     */
    public function getValue($name, $escape = true)
    {
        $value = $this->valueManager->getValue($name);

        if ($escape === true && !empty($value)) {
            $escapeHelper = $this->view->plugin('escapeHtml');
            $value = $escapeHelper($value);
        }

        return $value;
    }

    /**
     * @param  string|null $name
     * @return bool
     */
    public function hasError($name = null)
    {
        return $this->valueManager->hasErrors($name);
    }
}
<commit_msg>first draft valuemanger<commit_after><?php
namespace Core42\View\Helper;

use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\View\Helper\AbstractHelper;

class ValueManager extends AbstractHelper implements ServiceLocatorAwareInterface
{
    /**
     * @var \Core42\ValueManager\ValueManager
     */
    private $valueManager;

    /**
     * @var ServiceLocatorInterface
     */
    private $serviceLocator;

    /**
     * @var null|array
     */
    private $partialMapping = array(
        '*' => 'partial/value-manager/input',
    );

    /**
     * @return \Core42\View\Helper\ValueManager
     */
    public function __invoke()
    {
        return $this;
    }

    /**
     * @param  \Core42\ValueManager\ValueManager $valueManager
     * @return \Core42\View\Helper\ValueManager
     */
    public function setValueManager(\Core42\ValueManager\ValueManager $valueManager)
    {
        $this->valueManager = $valueManager;

        return $this;
    }

    /**
     * @param string $name
     * @param string $partial
     * @param array $options
     * @return mixed
     */
    public function render($name, $partial, array $options = array())
    {
        $partialHelper = $this->view->plugin('partial');

        if ($this->partialMapping === null) {
            $config = $this->getServiceManager()->get("Config");
            $this->partialMapping = $config['value_manager']['template_map'];
        }

        if (!array_key_exists($partial, $this->partialMapping)) {
            $partial = "*";
        }

        $partialName = $this->partialMapping[$partial];

        $model = array(
            'name'              => $name,
            'valueManager'      => $this->valueManager,
        );

        $model = array_merge($model, $options);

        return $partialHelper($partialName, $model);
    }

    /**
     * Set service locator
     *
     * @param ServiceLocatorInterface $serviceLocator
     */
    public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
    {
        $this->serviceLocator = $serviceLocator;
    }

    /**
     * Get service locator
     *
     * @return ServiceLocatorInterface
     */
    public function getServiceLocator()
    {
        return $this->serviceLocator;
    }

    /**
     * @return ServiceManager
     */
    public function getServiceManager()
    {
        return $this->getServiceLocator()->getServiceLocator();
    }
}

{'fraction_non_alphanumeric': 0.13157894736842105, 'fraction_numerical': 0.005847953216374269, 'mean_word_length': 2.2178002894356004, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '3505798', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1250, 'n_words': 231}