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

AxeWP / wp-graphql-rank-math / 8574391893

05 Apr 2024 06:49PM UTC coverage: 92.396%. Remained the same
8574391893

push

github

web-flow
ci: update actions and test against WP 6.5.0 (#83)

* ci: update actions and test against WP 6.5.0

* ci: drop PHP 8.0 from WP 6.5

* ci: update deprecations

2564 of 2775 relevant lines covered (92.4%)

11.27 hits per line

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

58.82
/src/Modules/Redirection/Data/Loader/RedirectionsLoader.php
1
<?php
2
/**
3
 * DataLoader - Redirections
4
 *
5
 * @package WPGraphQL\RankMath\Modules\Redirection\Data\Loader
6
 */
7

8
namespace WPGraphQL\RankMath\Modules\Redirection\Data\Loader;
9

10
use GraphQL\Error\UserError;
11
use WPGraphQL\Data\Loader\AbstractDataLoader;
12
use WPGraphQL\RankMath\Modules\Redirection\Model\Redirection;
13
use WPGraphQL\RankMath\Utils\RMUtils;
14

15
/**
16
 * Class - RedirectionsLoader
17
 */
18
class RedirectionsLoader extends AbstractDataLoader {
19
        /**
20
         * Loader name.
21
         *
22
         * @var string
23
         */
24
        public static string $name = 'redirections';
25

26
        /**
27
         * {@inheritDoc}
28
         */
29
        protected function get_model( $entry, $key ): Redirection {
30
                return new Redirection( $entry );
8✔
31
        }
32

33
        /**
34
         * {@inheritDoc}
35
         *
36
         * @throws \GraphQL\Error\UserError If a redirection does not exist.
37
         */
38
        protected function loadKeys( array $keys ) {
39
                if ( empty( $keys ) ) {
2✔
40
                        return $keys;
×
41
                }
42

43
                $table = RMUtils::get_redirections_table();
2✔
44

45
                $redirections = $table->where( 'id', 'IN', $keys )->get( ARRAY_A );
2✔
46

47
                $loaded = [];
2✔
48

49
                foreach ( $keys as $key ) {
2✔
50
                        $index = array_search( $key, array_column( $redirections, 'id' ) );
2✔
51
                        if ( ! isset( $redirections[ $index ] ) ) {
2✔
52
                                throw new UserError(
×
53
                                        sprintf(
×
54
                                                // translators: %s is the redirection ID.
55
                                                esc_html__( 'Redirection with ID "%s" does not exist.', 'wp-graphql-rank-math' ),
×
56
                                                esc_html( (string) $key )
×
57
                                        ),
×
58
                                );
×
59
                        }
60

61
                        $loaded[ $key ] = $redirections[ $index ];
2✔
62
                }
63

64
                return $loaded;
2✔
65
        }
66
}
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