public function justify($width = 79, $last_line = 'left', $cut = PHP_EOL)
    {
        self::mustBeInteger($width, 'Width');
        self::mustBeString($cut, 'Cut character');

        if (!in_array($last_line, array('left', 'right'))) {
            throw new \InvalidArgumentException(
                'Alignment of last line must be "left" or "right"'
            );
        }

        if (is_object($width)) {
            $width = $width->int;
        }

        if($width <= 0){
            throw new \InvalidArgumentException('Width cannot be null or negative!');
        }


        $a = $this
            ->strip()
            ->replace('/\s+/', ' ')
            ->wrap($width, $cut)
            ->split('/'.preg_quote($cut, '/').'/u');

        $s = '';
        $sp = new S(' ');

        if (count($a) == 1) {
            unset($a);

            return $this->$last_line($width, $cut);
        } while ($a->valid()) {
            if ($a->is_last) {
                $s .= $a->current->$last_line($width, $cut);
            } else {
                $line = $a->current->strip;
                $diff = $width - count($line);
                $words = $line->split('/\s/u');
                $nb_spaces = count($words) - 1 + $diff;
                $div = (double) $nb_spaces / (count($words) - 1);
                $div_floor = (int) floor($div);

                $missing = (count($words) - 1) * ($div - $div_floor);
                $sp_pad = $sp->times($div_floor);

                while ($words->valid()) {
                    if (!$words->is_last && count($sp_pad)) {
                        $s .= $words->current->append($sp_pad);

                        if ($missing > 0) {
                            $s .= $sp;
                            $missing--;
                        }
                    } else {
                        $s .= $words->current;
                    }
                    $words->next();
                }
                $s .= $cut;
            }
            $a->next();
        }

        return new S($s);
    }