<commit_before><?php

namespace jjok\Scheduler;


final class Time
{
    private $hour;
    private $minutes;
    private $seconds;

    public function __construct(int $hour, int $minutes = 0, int $seconds = 0)
    {
        if($hour < 0 || $hour > 23) {
            throw new \InvalidArgumentException('Hour must be between 0 and 23.');
        }

        if($minutes < 0 || $minutes > 59) {
            throw new \InvalidArgumentException('Minutes must be between 0 and 59.');
        }

        if($seconds < 0 || $seconds > 59) {
            throw new \InvalidArgumentException('Seconds must be between 0 and 59.');
        }

        $this->hour = $hour;
        $this->minutes = $minutes;
        $this->seconds = $seconds;
    }

    public static function fromString(string $time) : Time
    {
        list($hour, $minutes, $seconds) = sscanf($time, '%u:%u:%u');

        return new static($hour, $minutes, $seconds);
    }

    public function toString() : string
    {
        return sprintf(
            '%s:%s:%s',
            str_pad($this->hour, 2, '0', \STR_PAD_LEFT),
            str_pad($this->minutes, 2, '0', \STR_PAD_LEFT),
            str_pad($this->seconds, 2, '0', \STR_PAD_LEFT)
        );
    }

    public function isBefore(Time $other)
    {
        return $this->toString() < $other->toString();
    }

    public function isAfter(Time $other)
    {
        return $this->toString() > $other->toString();
    }

//    public function isDuring(Period $period) : bool
//    {
//        return $period->contains($this);
//    }
}<commit_msg>Refactor Time class<commit_after><?php

namespace jjok\Scheduler;

final class Time
{
    private $hour;
    private $minutes;
    private $seconds;

    public function __construct(int $hour, int $minutes = 0, int $seconds = 0)
    {
        if($hour < 0 || $hour > 23) {
            throw new \InvalidArgumentException('Hour must be between 0 and 23.');
        }

        if($minutes < 0 || $minutes > 59) {
            throw new \InvalidArgumentException('Minutes must be between 0 and 59.');
        }

        if($seconds < 0 || $seconds > 59) {
            throw new \InvalidArgumentException('Seconds must be between 0 and 59.');
        }

        $this->hour = $hour;
        $this->minutes = $minutes;
        $this->seconds = $seconds;
    }

    public static function fromString(string $time) : Time
    {
        list($hour, $minutes, $seconds) = sscanf($time, '%u:%u:%u');

        return new static($hour, $minutes, $seconds);
    }

    public function toString() : string
    {
        return sprintf(
            '%s:%s:%s',
            $this->intToTwoCharString($this->hour),
            $this->intToTwoCharString($this->minutes),
            $this->intToTwoCharString($this->seconds)
        );
    }

    private function intToTwoCharString(int $number) : string
    {
        return str_pad($number, 2, '0', \STR_PAD_LEFT);
    }

    public function isBefore(Time $other) : bool
    {
        return $this->toString() < $other->toString();
    }

    public function isAfter(Time $other) : bool
    {
        return $this->toString() > $other->toString();
    }

//    public function isDuring(Period $period) : bool
//    {
//        return $period->contains($this);
//    }
}
{'fraction_non_alphanumeric': 0.1465279902110737, 'fraction_numerical': 0.014683389415723462, 'mean_word_length': 2.16247582205029, 'pattern_counts': {'":': 0, '<': 13, '<?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': '858809', 'n_tokens_mistral': 1042, 'n_tokens_neox': 960, 'n_words': 251}