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.
Passed
Push — master ( aac044...cc3c72 )
by Leonardo
14:28
created

AbstractDocAboutMenuPage::getRelativePathDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI\ConditionalOnEnvironment\Admin\Services\MenuPages;
6
7
use InvalidArgumentException;
8
use GraphQLAPI\GraphQLAPI\General\RequestParams;
9
use GraphQLAPI\GraphQLAPI\Facades\ContentProcessors\MarkdownContentParserFacade;
10
11
/**
12
 * Open documentation within the About page
13
 */
14
abstract class AbstractDocAboutMenuPage extends AbstractDocsMenuPage
15
{
16
    protected function openInModalWindow(): bool
17
    {
18
        return true;
19
    }
20
21
    /**
22
     * Enable "/" in the filename
23
     *
24
     * @param string[] $specialChars
25
     * @return string[]
26
     */
27
    public function enableSpecialCharsForSanitization(array $specialChars): array
28
    {
29
        return array_diff(
30
            $specialChars,
31
            [
32
                '/',
33
            ]
34
        );
35
    }
36
37
    protected function getRelativePathDir(): string
38
    {
39
        return '';
40
    }
41
42
    protected function getContentToPrint(): string
43
    {
44
        // Enable "/" in the filename
45
        add_filter(
46
            'sanitize_file_name_chars',
47
            [$this, 'enableSpecialCharsForSanitization']
48
        );
49
        $filename = $_REQUEST[RequestParams::DOC] ?? '';
50
        $doc = \sanitize_file_name($filename . '.md');
51
        remove_filter(
52
            'sanitize_file_name_chars',
53
            [$this, 'enableSpecialCharsForSanitization']
54
        );
55
        $markdownContentParser = MarkdownContentParserFacade::getInstance();
56
        try {
57
            return $markdownContentParser->getContent($doc, $this->getRelativePathDir());
58
        } catch (InvalidArgumentException $e) {
59
            return sprintf(
60
                '<p>%s</p>',
61
                sprintf(
62
                    \__('Page \'%s\' does not exist', 'graphql-api'),
63
                    $doc
64
                )
65
            );
66
        }
67
    }
68
}
69