<commit_before><?php

namespace PHPOrchestra\ModelBundle\Validator\Constraints;

use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Doctrine\ODM\MongoDB\DocumentManager;

/**
 * Class StatusChangeValidator
 */
class StatusChangeValidator extends ConstraintValidator
{
    protected $securityContext;
    protected $documentManager;
    protected $translator;

    /**
     * @param SecurityContextInterface $securityContext
     * @param Translator               $translator
     * @param DocumentManager          $documentManager
     */
    public function __construct(
        SecurityContextInterface $securityContext,
        Translator $translator,
        DocumentManager $documentManager
    )
    {
        $this->securityContext = $securityContext;
        $this->documentManager = $documentManager;
        $this->translator = $translator;
    }

    /**
     * Checks if the passed value is valid.
     *
     * @param mixed      $value      The value that should be validated
     * @param Constraint $constraint The constraint for the validation
     */
    public function validate($value, Constraint $constraint)
    {
        if (is_null($oldNode = $this->documentManager->getUnitOfWork()->getOriginalDocumentData($value))) {
            return;
        }

        $oldStatus = $oldNode->getStatus();
        $status = $value->getStatus();

        if ($oldStatus == $status) {
            return;
        }

        $toRoles = array();
        foreach ($status->getToRoles() as $toRole) {
            $toRoles[] = $toRole->getName();
        }

        $fromRoles = array();<commit_msg>Update StatusChangeValidator.php<commit_after><?php

namespace PHPOrchestra\ModelBundle\Validator\Constraints;

use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Doctrine\ODM\MongoDB\DocumentManager;

/**
 * Class StatusChangeValidator
 */
class StatusChangeValidator extends ConstraintValidator
{
    protected $securityContext;
    protected $documentManager;
    protected $translator;

    /**
     * @param SecurityContextInterface $securityContext
     * @param Translator               $translator
     * @param DocumentManager          $documentManager
     */
    public function __construct(
        SecurityContextInterface $securityContext,
        Translator $translator,
        DocumentManager $documentManager
    )
    {
        $this->securityContext = $securityContext;
        $this->documentManager = $documentManager;
        $this->translator = $translator;
    }

    /**
     * Checks if the passed value is valid.
     *
     * @param mixed      $value      The value that should be validated
     * @param Constraint $constraint The constraint for the validation
     */
    public function validate($value, Constraint $constraint)
    {
        if (empty($oldNode = $this->documentManager->getUnitOfWork()->getOriginalDocumentData($value))) {
            return;
        }

        $oldStatus = $oldNode['status'];
        $status = $value->getStatus();

        if ($oldStatus == $status) {
            return;
        }

        $toRoles = array();
        foreach ($status->getToRoles() as $toRole) {
            $toRoles[] = $toRole->getName();
        }

        $fromRoles = array();
{'fraction_non_alphanumeric': 0.10203504804974561, 'fraction_numerical': 0.0, 'mean_word_length': 2.780982905982906, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '6813868', 'n_tokens_mistral': 913, 'n_tokens_neox': 900, 'n_words': 200}