Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
52.94% covered (danger)
52.94%
9 / 17
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Credentials
52.94% covered (danger)
52.94%
9 / 17
66.67% covered (warning)
66.67%
2 / 3
3.94
0.00% covered (danger)
0.00%
0 / 1
 init
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 addSettingsSection
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 sectionCallback
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Settings > BeyondWords > Credentials
7 *
8 * @package Beyondwords\Wordpress
9 * @author  Stuart McAlpine <stu@beyondwords.io>
10 * @since   5.0.0
11 */
12
13namespace Beyondwords\Wordpress\Component\Settings\Tabs\Credentials;
14
15use Beyondwords\Wordpress\Component\Settings\Fields\ApiKey\ApiKey;
16use Beyondwords\Wordpress\Component\Settings\Fields\ProjectId\ProjectId;
17
18/**
19 * "Credentials" settings tab
20 *
21 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22 *
23 * @since 5.0.0
24 */
25class Credentials
26{
27    /**
28     * Init
29     *
30     * @since 5.0.0
31     */
32    public function init()
33    {
34        (new ApiKey())->init();
35        (new ProjectId())->init();
36
37        add_action('admin_init', array($this, 'addSettingsSection'), 5);
38    }
39
40    /**
41     * Add Settings sections.
42     *
43     * @since 5.0.0
44     */
45    public function addSettingsSection()
46    {
47        add_settings_section(
48            'credentials',
49            __('Credentials', 'speechkit'),
50            array($this, 'sectionCallback'),
51            'beyondwords_credentials',
52        );
53    }
54
55    /**
56     * Section callback
57     *
58     * @since 5.0.0
59     *
60     * @return void
61     **/
62    public function sectionCallback()
63    {
64        ?>
65        <p class="description">
66            <?php
67            esc_html_e(
68                'Please add your Project ID and API key to authenticate your BeyondWords account.', // phpcs:ignore Generic.Files.LineLength.TooLong
69                'speechkit'
70            );
71            ?>
72        </p>
73        <?php
74    }
75}