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.

BlockRenderingHelpers::getCustomPostTitle()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 4
nop 1
dl 0
loc 15
ccs 0
cts 5
cp 0
crap 12
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI\General;
6
7
use WP_Post;
8
9
class BlockRenderingHelpers
10
{
11
    /**
12
     * Get a standardized title for a Custom Post
13
     */
14
    public static function getCustomPostTitle(WP_Post $customPostObject): string
15
    {
16
        $title = $customPostObject->post_title ?
17
            $customPostObject->post_title :
18
            \__('(No title)', 'graphql-api');
19
20
        // If the post is either draft/pending (or maybe trash?), add that info in the title
21
        if ($customPostObject->post_status != 'publish') {
22
            $title = sprintf(
23
                \__('(%s) %s', 'graphql-api'),
24
                ucwords($customPostObject->post_status),
25
                $title
26
            );
27
        }
28
        return $title;
29
    }
30
}
31