Completed
Push — master ( 261499...3196a9 )
by Beñat
07:26
created

Wysiwyg::toolbars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the WPFoundation library.
5
 *
6
 * Copyright (c) 2015 LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\WPFoundation\Configuration\Acf;
13
14
/**
15
 * Custom ACF Wysiwyg class adding some useful features.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 * @author Jon Torrado <[email protected]>
19
 */
20
class Wysiwyg
21
{
22
    /**
23
     * Constructor.
24
     *
25
     * @param array $toolbars Array which contains toolbar
26
     */
27
    public function __construct($toolbars)
28
    {
29
        $this->toolbars = $toolbars;
0 ignored issues
show
Bug introduced by
The property toolbars does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
        add_filter('acf/fields/wysiwyg/toolbars', [$this, 'toolbars']);
0 ignored issues
show
Unused Code introduced by
The call to the function add_filter() seems unnecessary as the function has no side-effects.
Loading history...
31
    }
32
33
    /**
34
     * Callback method that manages the Wysiwyg toolbars.
35
     *
36
     * @param array $toolbars Array which contains the toolbars
37
     *
38
     * @return array
39
     */
40
    public function toolbars(array $toolbars)
41
    {
42
        return array_merge($toolbars, $this->toolbars);
43
    }
44
}
45