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.
@@ 891-902 (lines=12) @@
888
   *
889
   * @return Stringy Object with its $str being the last $n chars
890
   */
891
  public function last($n)
892
  {
893
    $stringy = static::create($this->str, $this->encoding);
894
895
    if ($n <= 0) {
896
      $stringy->str = '';
897
    } else {
898
      return $stringy->substr(-$n);
899
    }
900
901
    return $stringy;
902
  }
903
904
  /**
905
   * Splits on newlines and carriage returns, returning an array of Stringy