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

wp-graphql / wp-graphql / 14716683875

28 Apr 2025 07:58PM UTC coverage: 84.287% (+1.6%) from 82.648%
14716683875

push

github

actions-user
release: merge develop into master for v2.3.0

15905 of 18870 relevant lines covered (84.29%)

257.23 hits per line

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

91.67
/src/Data/Loader/PostTypeLoader.php
1
<?php
2
namespace WPGraphQL\Data\Loader;
3

4
use WPGraphQL\Model\PostType;
5

6
/**
7
 * Class PostTypeLoader
8
 *
9
 * @package WPGraphQL\Data\Loader
10
 */
11
class PostTypeLoader extends AbstractDataLoader {
12

13
        /**
14
         * {@inheritDoc}
15
         *
16
         * @param mixed|\WP_Post_Type $entry The Post Type Object
17
         *
18
         * @return \WPGraphQL\Model\PostType
19
         */
20
        protected function get_model( $entry, $key ) {
21✔
21
                return new PostType( $entry );
21✔
22
        }
23

24
        /**
25
         * {@inheritDoc}
26
         *
27
         * @param string[] $keys
28
         * @return array<string,\WP_Post_Type|null>
29
         */
30
        public function loadKeys( array $keys ) {
22✔
31
                $post_types = \WPGraphQL::get_allowed_post_types( 'objects' );
22✔
32

33
                if ( empty( $post_types ) ) {
22✔
34
                        return [];
×
35
                }
36

37
                $loaded = [];
22✔
38

39
                foreach ( $keys as $key ) {
22✔
40
                        if ( isset( $post_types[ $key ] ) ) {
22✔
41
                                $loaded[ $key ] = $post_types[ $key ];
21✔
42
                        } else {
43
                                $loaded[ $key ] = null;
1✔
44
                        }
45
                }
46

47
                return $loaded;
22✔
48
        }
49
}
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