Code Duplication    Length = 12-12 lines in 2 locations

src/Stringy.php 2 locations

@@ 606-617 (lines=12) @@
603
   *
604
   * @return static  Object with its $str being the first $n chars
605
   */
606
  public function first($n)
607
  {
608
    $stringy = static::create($this->str, $this->encoding);
609
610
    if ($n < 0) {
611
      $stringy->str = '';
612
    } else {
613
      return $stringy->substr(0, $n);
614
    }
615
616
    return $stringy;
617
  }
618
619
  /**
620
   * Returns the encoding used by the Stringy object.
@@ 994-1005 (lines=12) @@
991
   *
992
   * @return static  Object with its $str being the last $n chars
993
   */
994
  public function last($n)
995
  {
996
    $stringy = static::create($this->str, $this->encoding);
997
998
    if ($n <= 0) {
999
      $stringy->str = '';
1000
    } else {
1001
      return $stringy->substr(-$n);
1002
    }
1003
1004
    return $stringy;
1005
  }
1006
1007
  /**
1008
   * Splits on newlines and carriage returns, returning an array of Stringy