Completed
Pull Request — master (#2)
by Beñat
02:35
created

Form   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 66
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A screenOptions() 0 8 1
A display() 0 22 1
1
<?php
2
3
namespace LIN3S\WPSymfonyForm\Admin\Views;
4
5
use LIN3S\WPSymfonyForm\Admin\Views\Components\LogsTable;
6
7
/**
8
 * Single form page.
9
 *
10
 * @author Beñat Espiña <[email protected]>
11
 */
12
class Form implements Page
13
{
14
    /**
15
     * The logs table component.
16
     *
17
     * @var LogsTable
18
     */
19
    private $logsTable;
20
21
    /**
22
     * The form type name.
23
     *
24
     * @var string
25
     */
26
    private $formType;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param string    $formType  The form type name
32
     * @param LogsTable $logsTable The logs table component
33
     */
34
    public function __construct($formType, LogsTable $logsTable)
35
    {
36
        $this->formType = $formType;
37
        $this->logsTable = $logsTable;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function display()
44
    {
45
        $wpLogsTable = $this->logsTable->load();
46
        $wpLogsTable->prepare_items(); ?>
47
        <div class="wrap">
48
            <h2>
49
                <?php _e('Sent emails logs of ', \WPSymfonyForm::TRANSLATION_DOMAIN); ?>
50
51
                <?php echo '"' . $this->formType . '"' ?>
52
            </h2>
53
            <div id="poststuff">
54
                <div id="post-body" class="metabox-holder">
55
                    <div id="post-body-content">
56
                        <?php $wpLogsTable->display() ?>
57
                    </div>
58
                </div>
59
                <br class="clear">
60
            </div>
61
        </div>
62
        <?php
63
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function screenOptions()
70
    {
71
        add_screen_option('per_page', [
72
            'label'   => 'Logs',
73
            'default' => 10,
74
            'option'  => 'logs_per_page',
75
        ]);
76
    }
77
}
78