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

AxeWP / wp-graphql-rank-math / 10339001339

11 Aug 2024 10:22AM UTC coverage: 89.142% (-0.06%) from 89.203%
10339001339

push

github

web-flow
release: 0.3.1 (#107)

* chore: version bump

* chore: regenerate autoloader

* fix: ensure autoloader compatibility when installed as Composer package.

* chore: phpcs issues

* chore: regenerate Composer autoloader

0 of 2 new or added lines in 1 file covered. (0.0%)

2586 of 2901 relevant lines covered (89.14%)

10.88 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
declare( strict_types = 1 );
9

10
namespace WPGraphQL\RankMath\Modules\Redirection\Data\Loader;
11

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

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

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

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

45
                $table = RMUtils::get_redirections_table();
2✔
46

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

49
                $loaded = [];
2✔
50

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

63
                        $loaded[ $key ] = $redirections[ $index ];
2✔
64
                }
65

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