Code Duplication    Length = 15-15 lines in 2 locations

src/Stringy.php 2 locations

@@ 2327-2341 (lines=15) @@
2324
     * @return static
2325
     *                <p>Object whose $str has had tabs switched to spaces.</p>
2326
     */
2327
    public function toSpaces(int $tabLength = 4): self
2328
    {
2329
        if ($tabLength === 4) {
2330
            $tab = '    ';
2331
        } elseif ($tabLength === 2) {
2332
            $tab = '  ';
2333
        } else {
2334
            $tab = \str_repeat(' ', $tabLength);
2335
        }
2336
2337
        return static::create(
2338
            \str_replace("\t", $tab, $this->str),
2339
            $this->encoding
2340
        );
2341
    }
2342
2343
    /**
2344
     * Return Stringy object as string, but you can also use (string) for automatically casting the object into a
@@ 2364-2378 (lines=15) @@
2361
     * @return static
2362
     *                <p>Object whose $str has had spaces switched to tabs.</p>
2363
     */
2364
    public function toTabs(int $tabLength = 4): self
2365
    {
2366
        if ($tabLength === 4) {
2367
            $tab = '    ';
2368
        } elseif ($tabLength === 2) {
2369
            $tab = '  ';
2370
        } else {
2371
            $tab = \str_repeat(' ', $tabLength);
2372
        }
2373
2374
        return static::create(
2375
            \str_replace($tab, "\t", $this->str),
2376
            $this->encoding
2377
        );
2378
    }
2379
2380
    /**
2381
     * Converts the first character of each word in the string to uppercase