Code Duplication    Length = 14-15 lines in 2 locations

src/PfPageparser.php 2 locations

@@ 76-89 (lines=14) @@
73
     * @param bool $is_regex
74
     * @return $this
75
     */
76
    public function trim_before($pattern,$is_regex=false): PfPageparser
77
    {
78
        if($is_regex){
79
            $matches=[];
80
            if($found=preg_match($pattern,$this->content,$matches)){
81
                $this->content=substr($this->content,$found); // trim before
82
            }
83
        } else {
84
            if($found=strpos($this->content,$pattern)){
85
                $this->content=substr($this->content,$found); // trim before
86
            }
87
        }
88
        return $this;
89
    }
90
91
    /**
92
     * @param $pattern
@@ 96-110 (lines=15) @@
93
     * @param bool $is_regex
94
     * @return $this
95
     */
96
    public function trim_after($pattern,$is_regex=false): PfPageparser
97
    {
98
        if($is_regex){
99
            $matches=[];
100
            if($found=preg_match($pattern,$this->content,$matches)){
101
                $this->content=substr($this->content,0,$found); // trim after
102
            }
103
        } else {
104
            if($found=strpos($this->content,$pattern)){
105
                $this->content=substr($this->content,0,$found + strlen($pattern)); // trim after
106
            }
107
        }
108
        return $this;
109
110
    }
111
112
    /**
113
     * @param string $before