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

AxeWP / wp-graphql-headless-login / #77

03 Aug 2025 09:57PM UTC coverage: 82.325% (-0.2%) from 82.559%
#77

push

php-coveralls

web-flow
Merge 30a6f1f59 into ecab1fdba

2287 of 2778 relevant lines covered (82.33%)

24.01 hits per line

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

62.5
/src/Main.php
1
<?php
2
/**
3
 * Initializes a singleton instance of the plugin.
4
 *
5
 * @package WPGraphQL\Login
6
 */
7

8
declare( strict_types = 1 );
9

10
namespace WPGraphQL\Login;
11

12
use WPGraphQL\Login\Admin\Settings;
13
use WPGraphQL\Login\Admin\UserProfile;
14
use WPGraphQL\Login\Auth\ProviderRegistry;
15
use WPGraphQL\Login\Vendor\AxeWP\GraphQL\Helper\Helper;
16

17
if ( ! class_exists( \WPGraphQL\Login\Main::class ) ) :
×
18

19
        /**
20
         * Class - Main
21
         */
22
        final class Main {
23
                /**
24
                 * Class instances.
25
                 *
26
                 * @var ?self $instance
27
                 */
28
                private static $instance;
29

30
                /**
31
                 * Constructor
32
                 */
33
                public static function instance(): self {
34
                        if ( ! isset( self::$instance ) ) {
3✔
35
                                // You cant test a singleton.
36
                                // @codeCoverageIgnoreStart .
37

38
                                self::$instance = new self();
×
39
                                self::$instance->setup();
×
40
                                // @codeCoverageIgnoreEnd
41
                        }
42

43
                        /**
44
                         * Fire off init action.
45
                         *
46
                         * @param self $instance the instance of the plugin class.
47
                         */
48
                        do_action( 'graphql_login_init', self::$instance );
3✔
49

50
                        return self::$instance;
3✔
51
                }
52

53
                /**
54
                 * Sets up the schema.
55
                 *
56
                 * @codeCoverageIgnore
57
                 */
58
                private function setup(): void {
59
                        // Setup boilerplate hook prefix.
60
                        Helper::set_hook_prefix( 'graphql_login' );
61

62
                        // Setup plugin.
63
                        CoreSchemaFilters::init();
64
                        WoocommerceSchemaFilters::init();
65
                        Settings::init();
66
                        UserProfile::init();
67
                        ProviderRegistry::get_instance();
68

69
                        // Initialize plugin type registry.
70
                        add_action( get_graphql_register_action(), [ TypeRegistry::class, 'init' ] );
71
                }
72

73
                /**
74
                 * Throw error on object clone.
75
                 * The whole idea of the singleton design pattern is that there is a single object
76
                 * therefore, we don't want the object to be cloned.
77
                 *
78
                 * @return void
79
                 */
80
                public function __clone() {
81
                        // Cloning instances of the class is forbidden.
82
                        _doing_it_wrong( __FUNCTION__, esc_html__( 'The plugin Main class should not be cloned.', 'wp-graphql-headless-login' ), '0.0.1' );
1✔
83
                }
84

85
                /**
86
                 * Disable unserializing of the class.
87
                 */
88
                public function __wakeup(): void {
89
                        // De-serializing instances of the class is forbidden.
90
                        _doing_it_wrong( __FUNCTION__, esc_html__( 'De-serializing instances of the plugin Main class is not allowed.', 'wp-graphql-headless-login' ), '0.0.1' );
1✔
91
                }
92
        }
93
endif;
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

© 2026 Coveralls, Inc