ContactFormExtensionsVariable   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A submissions() 0 9 2
A name() 0 3 1
A recaptcha() 0 7 2
1
<?php
2
/**
3
 * schema plugin for Craft CMS 3.x.
4
 *
5
 * A fluent builder Schema.org types and ld+json generator based on Spatie's schema-org package
6
 *
7
 * @link      https://rias.be
8
 *
9
 * @copyright Copyright (c) 2017 Rias
10
 */
11
12
namespace rias\contactformextensions\variables;
13
14
use Craft;
15
use craft\elements\db\ElementQueryInterface;
16
use rias\contactformextensions\ContactFormExtensions;
17
use rias\contactformextensions\elements\ContactFormSubmission;
18
19
/**
20
 * @author    Rias
21
 *
22
 * @since     1.0.0
23
 */
24
class ContactFormExtensionsVariable
25
{
26
    public function name()
27
    {
28
        return ContactFormExtensions::$plugin->name;
29
    }
30
31
    public function recaptcha(string $localeOrAction = null)
32
    {
33
        if (ContactFormExtensions::$plugin->settings->recaptcha) {
34
            return ContactFormExtensions::$plugin->contactFormExtensionsService->getRecaptcha()->render($localeOrAction);
35
        }
36
37
        return '';
38
    }
39
40
    public function submissions($criteria = null): ElementQueryInterface
41
    {
42
        $query = ContactFormSubmission::find();
43
44
        if ($criteria) {
45
            Craft::configure($query, $criteria);
46
        }
47
48
        return $query;
49
    }
50
}
51