Code Duplication    Length = 12-12 lines in 2 locations

src/Stringy.php 2 locations

@@ 625-636 (lines=12) @@
622
   *
623
   * @return static <p>Object with its $str being the first $n chars.</p>
624
   */
625
  public function first($n)
626
  {
627
    $stringy = static::create($this->str, $this->encoding);
628
629
    if ($n < 0) {
630
      $stringy->str = '';
631
    } else {
632
      return $stringy->substr(0, $n);
633
    }
634
635
    return $stringy;
636
  }
637
638
  /**
639
   * Returns the encoding used by the Stringy object.
@@ 1114-1125 (lines=12) @@
1111
   *
1112
   * @return static <p>Object with its $str being the last $n chars.</p>
1113
   */
1114
  public function last($n)
1115
  {
1116
    $stringy = static::create($this->str, $this->encoding);
1117
1118
    if ($n <= 0) {
1119
      $stringy->str = '';
1120
    } else {
1121
      return $stringy->substr(-$n);
1122
    }
1123
1124
    return $stringy;
1125
  }
1126
1127
  /**
1128
   * Splits on newlines and carriage returns, returning an array of Stringy