Code Duplication    Length = 12-12 lines in 2 locations

src/Stringy.php 2 locations

@@ 548-559 (lines=12) @@
545
   *
546
   * @return Stringy Object with its $str being the first $n chars
547
   */
548
  public function first($n)
549
  {
550
    $stringy = static::create($this->str, $this->encoding);
551
552
    if ($n < 0) {
553
      $stringy->str = '';
554
    } else {
555
      return $stringy->substr(0, $n);
556
    }
557
558
    return $stringy;
559
  }
560
561
  /**
562
   * Returns the encoding used by the Stringy object.
@@ 897-908 (lines=12) @@
894
   *
895
   * @return Stringy Object with its $str being the last $n chars
896
   */
897
  public function last($n)
898
  {
899
    $stringy = static::create($this->str, $this->encoding);
900
901
    if ($n <= 0) {
902
      $stringy->str = '';
903
    } else {
904
      return $stringy->substr(-$n);
905
    }
906
907
    return $stringy;
908
  }
909
910
  /**
911
   * Splits on newlines and carriage returns, returning an array of Stringy