GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Compact::compact()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
namespace ProtoneMedia\LaravelMixins\String;
4
5
class Compact
6
{
7
    /**
8
     * Returns a function containing the macro.
9
     *
10
     * @return callable
11
     */
12
    public function compact(): callable
13
    {
14
        /**
15
         * Takes the first and last part of the string and glues them together with the seperator.
16
         */
17
        return function ($value, int $eachSide = 32, string $seperator = ' ... '): string {
18
            if (strlen($value) <= $eachSide * 2) {
19
                return $value;
20
            }
21
22
            return implode($seperator, [
23
                substr($value, 0, $eachSide),
24
                substr($value, $eachSide * -1),
25
            ]);
26
        };
27
    }
28
}
29