Code Duplication    Length = 12-12 lines in 2 locations

src/Stringy.php 2 locations

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