Code Duplication    Length = 12-12 lines in 2 locations

src/Stringy.php 2 locations

@@ 600-611 (lines=12) @@
597
   *
598
   * @return static  Object with its $str being the first $n chars
599
   */
600
  public function first($n)
601
  {
602
    $stringy = static::create($this->str, $this->encoding);
603
604
    if ($n < 0) {
605
      $stringy->str = '';
606
    } else {
607
      return $stringy->substr(0, $n);
608
    }
609
610
    return $stringy;
611
  }
612
613
  /**
614
   * Returns the encoding used by the Stringy object.
@@ 988-999 (lines=12) @@
985
   *
986
   * @return static  Object with its $str being the last $n chars
987
   */
988
  public function last($n)
989
  {
990
    $stringy = static::create($this->str, $this->encoding);
991
992
    if ($n <= 0) {
993
      $stringy->str = '';
994
    } else {
995
      return $stringy->substr(-$n);
996
    }
997
998
    return $stringy;
999
  }
1000
1001
  /**
1002
   * Splits on newlines and carriage returns, returning an array of Stringy