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

rtCamp / snapwp-helper / 15781515101

20 Jun 2025 02:44PM UTC coverage: 84.226% (+0.9%) from 83.349%
15781515101

Pull #113

github

web-flow
Merge 538a89b6b into fced6b317
Pull Request #113: feat!: bump minimum WPGraphQL version to v2.3.3

1714 of 2035 relevant lines covered (84.23%)

12.2 hits per line

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

82.35
/src/Modules/GraphQL/Model/ScriptModule.php
1
<?php
2
/**
3
 * ScriptModule Model class
4
 *
5
 * @package SnapWP\Helper\Modules\GraphQL\Model
6
 */
7

8
namespace SnapWP\Helper\Modules\GraphQL\Model;
9

10
use GraphQLRelay\Relay;
11
use WPGraphQL\Model\Model;
12

13
/**
14
 * Class - ScriptModule
15
 *
16
 * @phpcs:disable SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation
17
 *
18
 * @property string $id The Global ID of the script module.
19
 * @property string $handle The handle of the script module.
20
 * @property ?string $extraData The JSON-encoded data object for the script module.
21
 * @property ?string $src The source URL of the script module.
22
 * @property ?string $version The version of the script module.
23
 * @property ?array{id:string,import?:string} $dependencies The dependencies of the script module.
24
 *
25
 * @phpstan-import-type ScriptModuleData from \SnapWP\Helper\Modules\GraphQL\Utils\ScriptModuleUtils
26
 *
27
 * @extends \WPGraphQL\Model\Model<ScriptModuleData>
28
 *
29
 * @phpcs:enable SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation
30
 */
31
class ScriptModule extends Model {
32
        /**
33
         * Constructor.
34
         *
35
         * @param mixed[] $module The script module data.
36
         *
37
         * @throws \InvalidArgumentException If the required keys are not present in the resolved template data.
38
         */
39
        public function __construct( array $module ) {
3✔
40
                if ( ! isset( $module['src'] ) || ! isset( $module['id'] ) ) {
3✔
41
                        throw new \InvalidArgumentException(
×
42
                                esc_html__( 'Invalid script module data. The "src" and "id" keys are required.', 'snapwp-helper' )
×
43
                        );
×
44
                }
45

46
                /** @var ScriptModuleData $module */
47
                $this->data = $module;
3✔
48

49
                parent::__construct();
3✔
50
        }
51

52
        /**
53
         * {@inheritDoc}
54
         */
55
        protected function init() {
3✔
56
                if ( empty( $this->fields ) ) {
3✔
57
                        $this->fields = [
3✔
58
                                'id'           => fn (): string => Relay::toGlobalId( 'script_module', $this->data['id'] ),
3✔
59
                                'handle'       => fn (): ?string => $this->data['id'] ?: null,
3✔
60
                                'extraData'    => fn (): ?string => ! empty( $this->data['extraData'] ) ? $this->data['extraData'] : null,
3✔
61
                                'src'          => fn (): ?string => $this->data['src'] ?: null,
3✔
62
                                'version'      => fn (): ?string => ! empty( $this->data['version'] ) ? $this->data['version'] : null,
3✔
63
                                'dependencies' => fn (): ?array => ! empty( $this->data['dependencies'] ) ? $this->data['dependencies'] : null,
3✔
64
                        ];
3✔
65
                }
66
        }
67
}
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