<commit_before><?php

namespace Cercanias;

use Cercanias\Exception\OutOfBoundsException;

class Trip
{
    protected
        $departureTime,
        $arrivalTime;

    public function __construct(\DateTime $departureTime, \DateTime $arrivalTime = NULL)
    {
        $this->departureTime = $departureTime;
        $this->arrivalTime = $arrivalTime;
        if ($this->getArrivalTime()->getTimestamp() < $this->getDepartureTime()->getTimestamp()) {
            throw new OutOfBoundsException();
        }
    }

    public function getDepartureTime()
    {
        return $this->departureTime;
    }

    public function getArrivalTime()
    {
        return is_null($this->arrivalTime) ?
            $this->getDepartureTime() : $this->arrivalTime;
    }

    public function getDuration()
    {
        return $this->getDepartureTime()->diff($this->getArrivalTime());
    }
}<commit_msg>Refactor arrival time check.<commit_after><?php

namespace Cercanias;

use Cercanias\Exception\OutOfBoundsException;

class Trip
{
    protected
        $departureTime,
        $arrivalTime;

    public function __construct(\DateTime $departureTime, \DateTime $arrivalTime = NULL)
    {
        $this->departureTime = $departureTime;
        $this->arrivalTime = $arrivalTime;
        if ($this->isArrivalTimeOutOfBounds()) {
            throw new OutOfBoundsException();
        }
    }

    protected function isArrivalTimeOutOfBounds()
    {
        return ($this->getArrivalTime()->getTimestamp() < $this->getDepartureTime()->getTimestamp());
    }

    public function getDepartureTime()
    {
        return $this->departureTime;
    }

    public function getArrivalTime()
    {
        return is_null($this->arrivalTime) ?
            $this->getDepartureTime() : $this->arrivalTime;
    }

    public function getDuration()
    {
        return $this->getDepartureTime()->diff($this->getArrivalTime());
    }
}
{'fraction_non_alphanumeric': 0.12224554039874082, 'fraction_numerical': 0.0, 'mean_word_length': 2.814, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, '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': '7622626', 'n_tokens_mistral': 600, 'n_tokens_neox': 569, 'n_words': 96}