Code Duplication    Length = 12-12 lines in 2 locations

src/Stringy.php 2 locations

@@ 552-563 (lines=12) @@
549
   *
550
   * @return Stringy Object with its $str being the first $n chars
551
   */
552
  public function first($n)
553
  {
554
    $stringy = static::create($this->str, $this->encoding);
555
556
    if ($n < 0) {
557
      $stringy->str = '';
558
    } else {
559
      return $stringy->substr(0, $n);
560
    }
561
562
    return $stringy;
563
  }
564
565
  /**
566
   * Returns the encoding used by the Stringy object.
@@ 881-892 (lines=12) @@
878
   *
879
   * @return Stringy Object with its $str being the last $n chars
880
   */
881
  public function last($n)
882
  {
883
    $stringy = static::create($this->str, $this->encoding);
884
885
    if ($n <= 0) {
886
      $stringy->str = '';
887
    } else {
888
      return $stringy->substr(-$n);
889
    }
890
891
    return $stringy;
892
  }
893
894
  /**
895
   * Splits on newlines and carriage returns, returning an array of Stringy