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.
Completed
Pull Request — master (#51)
by
unknown
03:30
created

TestCaseSnapshot   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSnapshotId() 0 14 2
1
<?php
2
3
namespace Spatie\Snapshots;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Class TestCaseSnapshot.
9
 *
10
 * Special test case, supported Windows OS.
11
 *
12
 * @see {https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file}
13
 */
14
abstract class TestCaseSnapshot extends TestCase
15
{
16
    const WINDOWS_FILE_NAME_LENGTH_LIMIT = 255;
17
18
    use MatchesSnapshots;
19
20
    /**
21
     * @throws \ReflectionException
22
     * @throws \Exception
23
     *
24
     * @return string
25
     */
26
    protected function getSnapshotId(): string
27
    {
28
        $name = (new \ReflectionClass($this))->getShortName() . '_' .
29
            $this->getName() . '_' .
30
            $this->snapshotIncrementor;
31
32
        $replaced = \preg_replace('/(\s+|\W+)/ui', '_', $name);
33
34
        if (\mb_strlen($replaced) >= self::WINDOWS_FILE_NAME_LENGTH_LIMIT) {
35
            throw new \Exception('Very long filename, please rename test or test case name!');
36
        }
37
38
        return $replaced;
39
    }
40
}
41