<commit_before><?php
namespace Peppercorn\St1;

class File
{

    /**
     * Contains all lines from this file
     * @var array
     */
    private $lines;

    public function __construct($content)
    {
        $this->lines = self::splitContentIntoLines($content);
    }

    private static function splitContentIntoLines($content) {
        $rawLines = explode("\n", $content);
        $lines = array();
        foreach ($rawLines as $rawLine) {
            $line = trim($rawLine);
            if (strlen($line) > 0) { // omit empty lines
                $lines[] = $line;
            }
        }
        return $lines;
    }

    public function getLineCount() {
        return count($this->lines);
    }

    public function getLine($index) {
        assert('is_integer($index)');
        assert('$index >= 0');
        assert('$index < $this->getLineCount()');
        // TODO: confirm assert works with object scope in this way
        return $this->lines[$index];
    }

}<commit_msg>Initial Peppercorn\St1\File Preconditions<commit_after><?php
namespace Peppercorn\St1;

use Phava\Base;
use Phava\Base\Preconditions;
use Phava\Base\Strings;

class File
{

    /**
     * Contains all lines from this file
     * @var array
     */
    private $lines;

    public function __construct($content)
    {
        Preconditions::checkArgument(Strings::isNotEmpty($content));
        $this->lines = self::splitContentIntoLines($content);
    }

    private static function splitContentIntoLines($content) {
        $rawLines = explode("\n", $content);
        $lines = array();
        foreach ($rawLines as $rawLine) {
            $line = trim($rawLine);
            if (strlen($line) > 0) { // omit empty lines
                $lines[] = $line;
            }
        }
        return $lines;
    }

    public function getLineCount() {
        return count($this->lines);
    }

    public function getLine($index) {
        Preconditions::checkArgumentIsInteger($index);
        Preconditions::checkArgumentIsKeyInArray($index, $this->lines);

        return $this->lines[$index];
    }

}
{'fraction_non_alphanumeric': 0.13317422434367543, 'fraction_numerical': 0.002863961813842482, 'mean_word_length': 2.275, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 14, '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': '201376', 'n_tokens_mistral': 605, 'n_tokens_neox': 589, 'n_words': 137}