<commit_before><?php

namespace web\widgets\document;

/**
 * Renders document row
 */
class Row extends \web\ext\Widget
{

    /**
     * Document
     * @var \common\models\document
     */
    public $document;

    /**
     * Run widget
     */
    public function run()
    {
        // Define size
        $size = $this->document->file->getSize();
        if ($size < BYTES_IN_KB) {
            $sizeLabel = $size . ' b';
        } elseif ($size < BYTES_IN_MB) {
            $sizeLabel = number_format($size / BYTES_IN_KB, 2) . ' kb';
        } elseif ($size < BYTES_IN_GB) {
            $sizeLabel = number_format($size / BYTES_IN_MB, 2) . ' mb';
        } else {
            $sizeLabel = number_format($size / BYTES_IN_GB, 2) . ' gb';
        }

        // Render view
        $this->render('row', array(
            'sizeLabel' => $sizeLabel,
        ));
    }

}<commit_msg>Fixed displaying of document size<commit_after><?php

namespace web\widgets\document;

/**
 * Renders document row
 */
class Row extends \web\ext\Widget
{

    /**
     * Document
     * @var \common\models\document
     */
    public $document;

    /**
     * Run widget
     */
    public function run()
    {
        // Define size
        if ($this->document->file !== null) {
            $size = $this->document->file->getSize();
        } else {
            $size = 0;
        }
        if ($size < BYTES_IN_KB) {
            $sizeLabel = $size . ' b';
        } elseif ($size < BYTES_IN_MB) {
            $sizeLabel = number_format($size / BYTES_IN_KB, 2) . ' kb';
        } elseif ($size < BYTES_IN_GB) {
            $sizeLabel = number_format($size / BYTES_IN_MB, 2) . ' mb';
        } else {
            $sizeLabel = number_format($size / BYTES_IN_GB, 2) . ' gb';
        }

        // Render view
        $this->render('row', array(
            'sizeLabel' => $sizeLabel,
        ));
    }

}
{'fraction_non_alphanumeric': 0.1520127118644068, 'fraction_numerical': 0.003707627118644068, 'mean_word_length': 1.641958041958042, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5873557', 'n_tokens_mistral': 623, 'n_tokens_neox': 607, 'n_words': 126}