<commit_before><?php
namespace Metabor\Bridge\Doctrine\Statemachine;
use Doctrine\Common\Collections\ArrayCollection;

use MetaborStd\Statemachine\ProcessInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @author <NAME>
 * 
 * @ORM\Table()
 * @ORM\Entity
 *        
 */
class Process implements ProcessInterface
{
    const ENTITY_NAME = __CLASS__;

    /**
     * @var integer
     *
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(unique=true)
     */
    private $name;

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\OneToMany(targetEntity="State", mappedBy="process", indexBy="name", cascade={"persist", "remove"})
     */
    private $states;

    /**
     * @var State
     * 
     * @ORM\ManyToOne(targetEntity="State", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false)
     */
    private $initialState;

    /**
     * @param string $name
     * @param State $initialState
     */
    public function __construct($name = null, State $initialState = null)
    {
        $this->states = new ArrayCollection();
        $this->name = $name;
        $this->initialState = $initialState;
    }

    /**
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @see \Metabor\Named::getName()
     */
    public function getName()
    {
        return $this->getName();
    }

    /**
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @param State $initialState
     */
    public function setInitialState(State $initialState)
    {
        $this->initialState = $initialState;
        $this->addState($initialState);
    }

    /**
     * @see \MetaborStd\Statemachine\ProcessInterface::getInitialState()
     */
    public function getInitialState()
    {
        return $this->initialState;
    }

    /**
     * @see \MetaborStd\Statemachine\StateCollectionInterface::getStates()
     */
    public function getStates()
    {
        return $this->states;
    }

    /**
     * @param State $state
     */
    public function addState(State $state)
    {
        $this->states->set($state->getName(), $state);
    }

    /**
     * @param State $state
     */
    public function removeState(State $state)
    {
        $this->states->removeElement($state);
    }

    /**<commit_msg>changed relationship between process and state<commit_after><?php
namespace Metabor\Bridge\Doctrine\Statemachine;
use Doctrine\Common\Collections\ArrayCollection;

use MetaborStd\Statemachine\ProcessInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @author <NAME>
 * 
 * @ORM\Table()
 * @ORM\Entity
 *        
 */
class Process implements ProcessInterface
{
    const ENTITY_NAME = __CLASS__;

    /**
     * @var integer
     *
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(unique=true)
     */
    private $name;

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\OneToMany(targetEntity="State", mappedBy="process", indexBy="name", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    private $states;

    /**
     * @var State
     * 
     * @ORM\OneToOne(targetEntity="State", mappedBy="process", cascade={"persist", "remove"})
     * @ORM\JoinColumn(nullable=false)
     */
    private $initialState;

    /**
     * @param string $name
     * @param State $initialState
     */
    public function __construct($name = null, State $initialState = null)
    {
        $this->states = new ArrayCollection();
        $this->name = $name;
        if ($initialState) {
            $this->setInitialState($initialState);
        }
    }

    /**
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @see \Metabor\Named::getName()
     */
    public function getName()
    {
        return $this->getName();
    }

    /**
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @param State $initialState
     */
    public function setInitialState(State $initialState)
    {
        $this->initialState = $initialState;
        $this->addState($initialState);
    }

    /**
     * @see \MetaborStd\Statemachine\ProcessInterface::getInitialState()
     */
    public function getInitialState()
    {
        return $this->initialState;
    }

    /**
     * @see \MetaborStd\Statemachine\StateCollectionInterface::getStates()
     */
    public function getStates()
    {
        return $this->states;
    }

    /**
     * @param State $state
     */
    public function addState(State $state)
    {
        $state->setProcess($this);
        $this->states->set($state->getName(), $state);
    }

    /**
     * @param State $state
     */
    public function removeState(State $state)
    {
        $this->states->removeElement($state);
    }

    /**
{'fraction_non_alphanumeric': 0.14967041488949206, 'fraction_numerical': 0.0, 'mean_word_length': 2.1553516819571867, 'pattern_counts': {'":': 0, '<': 7, '<?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': '367585', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1566, 'n_words': 276}