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   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A compact() 0 13 2
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