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 ( cf39f6...a305e6 )
by Leonardo
03:52
created

HasMarkdownDocumentationModuleResolverTrait::addClasses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 6
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI\ModuleResolvers;
6
7
use GraphQLAPI\GraphQLAPI\ContentProcessors\ContentParserOptions;
8
use InvalidArgumentException;
9
use GraphQLAPI\GraphQLAPI\Facades\ContentProcessors\MarkdownContentParserFacade;
10
11
trait HasMarkdownDocumentationModuleResolverTrait
12
{
13
    /**
14
     * The module slug
15
     */
16
    abstract public function getSlug(string $module): string;
17
18
    /**
19
     * The name of the Markdown filename.
20
     * By default, it's the same as the slug
21
     *
22
     * @param string $module
23
     * @return string
24
     */
25
    public function getMarkdownFilename(string $module): ?string
26
    {
27
        return $this->getSlug($module) . '.md';
28
    }
29
30
    /**
31
     * Does the module have HTML Documentation?
32
     *
33
     * @param string $module
34
     * @return bool
35
     */
36
    public function hasDocumentation(string $module): bool
37
    {
38
        return !empty($this->getMarkdownFilename($module));
39
    }
40
41
    /**
42
     * HTML Documentation for the module
43
     *
44
     * @param string $module
45
     * @return string|null
46
     */
47
    public function getDocumentation(string $module): ?string
48
    {
49
        if ($markdownFilename = $this->getMarkdownFilename($module)) {
50
            $markdownContentParser = MarkdownContentParserFacade::getInstance();
51
            try {
52
                return $markdownContentParser->getContent(
53
                    'modules',
54
                    $markdownFilename,
55
                    [
56
                        ContentParserOptions::TAB_CONTENT => true,
57
                    ]
58
                );
59
            } catch (InvalidArgumentException $e) {
60
                return sprintf(
61
                    '<p>%s</p>',
62
                    \__('Oops, the documentation for this module is not available', 'graphql-api')
63
                );
64
            }
65
        }
66
        return null;
67
    }
68
}
69