• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AxeWP / wp-graphql-rank-math / 10331310134

10 Aug 2024 11:40AM UTC coverage: 90.23% (-0.2%) from 90.42%
10331310134

push

github

web-flow
fix: improve openGraph type handling (#104)

10 of 22 new or added lines in 5 files covered. (45.45%)

2 existing lines in 2 files now uncovered.

2586 of 2866 relevant lines covered (90.23%)

11.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.5
/src/Type/WPObject/OpenGraph/Article.php
1
<?php
2
/**
3
 * The Rank Math Facebook OpenGraph meta tags GraphQL Object.
4
 *
5
 * @package WPGraphQL\RankMath\Type\WPObject
6
 */
7

8
declare( strict_types = 1 );
9

10
namespace WPGraphQL\RankMath\Type\WPObject\OpenGraph;
11

12
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Abstracts\ObjectType;
13

14
/**
15
 * Class - Article
16
 */
17
class Article extends ObjectType {
18
        /**
19
         * {@inheritDoc}
20
         */
21
        protected static function type_name(): string {
22
                return 'OpenGraphArticle';
18✔
23
        }
24

25
        /**
26
         * {@inheritDoc}
27
         */
28
        public static function get_description(): string {
29
                return __( 'The OpenGraph Article meta.', 'wp-graphql-rank-math' );
18✔
30
        }
31

32
        /**
33
         * {@inheritDoc}
34
         */
35
        public static function get_fields(): array {
36
                return [
18✔
37
                        'modifiedTime'  => [
18✔
38
                                'type'        => 'String',
18✔
39
                                'description' => __( 'The date modified.', 'wp-graphql-rank-math' ),
18✔
40
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['modified_time'] ) ? (string) $source['modified_time'] : null,
18✔
41
                        ],
18✔
42
                        'publishedTime' => [
18✔
43
                                'type'        => 'String',
18✔
44
                                'description' => __( 'The date published.', 'wp-graphql-rank-math' ),
18✔
45
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['published_time'] ) ? (string) $source['published_time'] : null,
18✔
46
                        ],
18✔
47
                        'publisher'     => [
18✔
48
                                'type'        => 'String',
18✔
49
                                'description' => __( 'The publisher', 'wp-graphql-rank-math' ),
18✔
50
                        ],
18✔
51
                        'author'        => [
18✔
52
                                'type'        => 'String',
18✔
53
                                'description' => __( 'The author.', 'wp-graphql-rank-math' ),
18✔
54
                        ],
18✔
55
                        'tags'          => [
18✔
56
                                'type'        => [ 'list_of' => 'String' ],
18✔
57
                                'description' => __( 'The article tags.', 'wp-graphql-rank-math' ),
18✔
58
                                'resolve'     => static function ( $source ): ?array {
18✔
59
                                        $value = ! empty( $source['tag'] ) ? $source['tag'] : null;
×
60

NEW
61
                                        if ( empty( $value ) ) {
×
NEW
62
                                                return null;
×
63
                                        }
64

NEW
65
                                        if ( ! is_array( $value ) ) {
×
NEW
66
                                                $value = [ (string) $value ];
×
67
                                        }
68

69
                                        // Ensure all tags are strings.
NEW
70
                                        $value = array_map( 'strval', $value );
×
71

UNCOV
72
                                        return $value;
×
73
                                },
18✔
74
                        ],
18✔
75
                        'section'       => [
18✔
76
                                'type'        => 'String',
18✔
77
                                'description' => __( 'The article category.', 'wp-graphql-rank-math' ),
18✔
78
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['section'] ) ? (string) $source['section'] : null,
18✔
79
                        ],
18✔
80
                ];
18✔
81
        }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc