Mautic   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 4
dl 0
loc 109
rs 10
c 0
b 0
f 0
ccs 14
cts 16
cp 0.875

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseUrl() 0 4 1
A getForm() 0 4 1
A setContact() 0 6 1
A getContact() 0 4 1
A getCookie() 0 4 1
A getConfig() 0 4 1
A __construct() 0 7 2
1
<?php
2
3
namespace Escopecz\MauticFormSubmit;
4
5
use Escopecz\MauticFormSubmit\Mautic\Form;
6
use Escopecz\MauticFormSubmit\Mautic\Contact;
7
use Escopecz\MauticFormSubmit\Mautic\Cookie as MauticCookie;
8
use Escopecz\MauticFormSubmit\Mautic\Config;
9
10
/**
11
 * Mautic representation
12
 */
13
class Mautic
14
{
15
    /**
16
     * Mautic base (root) URL
17
     *
18
     * @var string
19
     */
20
    protected $baseUrl;
21
22
    /**
23
     * Mautic Contact
24
     *
25
     * @var Contact
26
     */
27
    protected $contact;
28
29
    /**
30
     * Mautic Contact Cookie
31
     *
32
     * @var MauticCookie
33
     */
34
    protected $cookie;
35
36
    /**
37
     * Mautic Configuration
38
     *
39
     * @var Config
40 26
     */
41
    protected $config;
42 26
43 26
    /**
44 26
     * Constructor
45 26
     *
46
     * @param string $baseUrl
47
     */
48
    public function __construct($baseUrl, Config $config = null)
49
    {
50
        $this->baseUrl = rtrim(trim($baseUrl), '/');
51
        $this->cookie = new MauticCookie;
52 6
        $this->contact = new Contact($this->cookie);
53
        $this->config = $config ?: new Config;
54 6
    }
55
56
    /**
57
     * Returns Mautic's base URL
58
     *
59
     * @return string
60
     */
61
    public function getBaseUrl()
62
    {
63
        return $this->baseUrl;
64 10
    }
65
66 10
    /**
67
     * Returns new Mautic Form representation object
68
     *
69
     * @param  int $id
70
     *
71
     * @return Form
72
     */
73
    public function getForm($id)
74
    {
75
        return new Form($this, $id);
76 2
    }
77
78 2
    /**
79
     * Sets the Mautic Contact if you want to replace the default one
80 2
     *
81
     * @param Contact $contact
82
     *
83
     * @return Mautic
84
     */
85
    public function setContact(Contact $contact)
86
    {
87
        $this->contact = $contact;
88 12
89
        return $this;
90 12
    }
91
92
    /**
93
     * Returns Mautic Contact representation object
94
     *
95
     * @return Contact
96
     */
97
    public function getContact()
98
    {
99
        return $this->contact;
100
    }
101
102
    /**
103
     * Returns Mautic Cookie representation object
104
     *
105
     * @return MauticCookie
106
     */
107
    public function getCookie()
108
    {
109
        return $this->cookie;
110
    }
111
112
    /**
113
     * Returns Mautic Configuration representation object
114
     *
115
     * @return Config
116
     */
117
    public function getConfig()
118
    {
119
        return $this->config;
120
    }
121
}
122