Completed
Branch EDTR/master (83b47e)
by
unknown
25:37 queued 16:41
created

EspressoCoreAppAssetManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 36.59 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 15
loc 41
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addAssets() 0 5 1
A registerJavascript() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace EventEspresso\core\domain\services\assets;
4
5
use DomainException;
6
use EventEspresso\core\exceptions\InvalidDataTypeException;
7
use EventEspresso\core\exceptions\InvalidEntityException;
8
use EventEspresso\core\services\collections\DuplicateCollectionIdentifierException;
9
10
/**
11
 * EspressoEditorAssetManager
12
 * assets for EE admin editors
13
 *
14
 * @package EventEspresso\core\domain\services\assets
15
 * @author  Brent Christensen
16
 * @since   $VID:$
17
 */
18
class EspressoCoreAppAssetManager extends ReactAssetManager
19
{
20
    const JS_HANDLE_EDITOR = 'eventespresso-core-app';
21
22
    /**
23
     * @throws InvalidDataTypeException
24
     * @throws InvalidEntityException
25
     * @throws DuplicateCollectionIdentifierException
26
     * @throws DomainException
27
     */
28
    public function addAssets()
29
    {
30
        parent::addAssets();
31
        $this->registerJavascript();
32
    }
33
34
35
    /**
36
     * Register javascript assets
37
     *
38
     * @throws InvalidDataTypeException
39
     * @throws InvalidEntityException
40
     * @throws DuplicateCollectionIdentifierException
41
     * @throws DomainException
42
     */
43 View Code Duplication
    private function registerJavascript()
44
    {
45
        $this->addJs(
46
            EspressoCoreAppAssetManager::JS_HANDLE_EDITOR,
47
            [
48
                ReactAssetManager::JS_HANDLE_REACT,
49
                ReactAssetManager::JS_HANDLE_REACT_DOM,
50
                CoreAssetManager::JS_HANDLE_JS_CORE,
51
                'wp-components',
52
                'wp-i18n',
53
                'wp-keycodes',
54
                'wp-url',
55
            ]
56
        )->setRequiresTranslation();
57
    }
58
}
59