<commit_before><?php
/**
 * Webino (http://webino.sk)
 *
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
 * @copyright   Copyright (c) 2012-2014 Webino, s. r. o. (http://webino.sk)
 * @author      <NAME> <<EMAIL>>
 * @license     BSD-3-Clause
 */

namespace WebinoDraw\Manipulator\Plugin;

use DOMElement;
use Zend\View\Helper\EscapeHtml;

/**
 *
 */
class Value extends AbstractPlugin implements InLoopPluginInterface
{
    /**
     * @var EscapeHtml
     */
    protected $escapeHtml;

    /**
     * @param EscapeHtml $escapeHtml
     */
    public function __construct(EscapeHtml $escapeHtml)
    {
        $this->escapeHtml = $escapeHtml;
    }

    /**
     * @param PluginArgument $arg
     */
    public function inLoop(PluginArgument $arg)
    {
        $spec = $arg->getSpec();
        if (!array_key_exists('value', $spec) || null === $spec['value']) {
            return;
        }

        $node = $arg->getNode();
        if (!($node instanceof DOMElement)) {
            throw new Exception\LogicException('Expected node of type DOMElement');
        }

        $varTranslation  = $arg->getVarTranslation();
        $translatedValue = $arg->getHelper()->translateValue($spec['value'], $varTranslation, $spec);
        $node->nodeValue = $this->escapeHtml->__invoke($varTranslation->removeVars($translatedValue));

        $this->updateNodeVarTranslation($node, $arg);
    }
}<commit_msg>Updated Manipulator\Plugin\Value, check that node is DOMNode instead of DOMElement<commit_after><?php
/**
 * Webino (http://webino.sk)
 *
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
 * @copyright   Copyright (c) 2012-2014 Webino, s. r. o. (http://webino.sk)
 * @author      <NAME> <<EMAIL>>
 * @license     BSD-3-Clause
 */

namespace WebinoDraw\Manipulator\Plugin;

use DOMNode;
use WebinoDraw\Exception;
use Zend\View\Helper\EscapeHtml;

/**
 *
 */
class Value extends AbstractPlugin implements InLoopPluginInterface
{
    /**
     * @var EscapeHtml
     */
    protected $escapeHtml;

    /**
     * @param EscapeHtml $escapeHtml
     */
    public function __construct(EscapeHtml $escapeHtml)
    {
        $this->escapeHtml = $escapeHtml;
    }

    /**
     * @param PluginArgument $arg
     */
    public function inLoop(PluginArgument $arg)
    {
        $spec = $arg->getSpec();
        if (!array_key_exists('value', $spec) || null === $spec['value']) {
            return;
        }

        $node = $arg->getNode();
        if (!($node instanceof DOMNode)) {
            throw new Exception\LogicException('Expected node of type DOMNode');
        }

        $varTranslation  = $arg->getVarTranslation();
        $translatedValue = $arg->getHelper()->translateValue($spec['value'], $varTranslation, $spec);
        $node->nodeValue = $this->escapeHtml->__invoke($varTranslation->removeVars($translatedValue));

        $this->updateNodeVarTranslation($node, $arg);
    }
}
{'fraction_non_alphanumeric': 0.14838492597577388, 'fraction_numerical': 0.006056527590847914, 'mean_word_length': 2.7776365946632784, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 2, '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': '2756114', 'n_tokens_mistral': 903, 'n_tokens_neox': 873, 'n_words': 185}