Completed
Push — master ( f813e0...5f1c56 )
by Thierry
03:59 queued 02:07
created

Autoload::useComposerAutoloader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Autoload.php - Upload Trait
5
 *
6
 * The Jaxon class uses a modular plug-in system to facilitate the processing
7
 * of special Ajax requests made by a PHP page.
8
 * It generates Javascript that the page must include in order to make requests.
9
 * It handles the output of response commands (see <Jaxon\Response\Response>).
10
 * Many flags and settings can be adjusted to effect the behavior of the Jaxon class
11
 * as well as the client-side javascript.
12
 *
13
 * @package jaxon-core
14
 * @author Thierry Feuzeu <[email protected]>
15
 * @copyright 2017 Thierry Feuzeu <[email protected]>
16
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
17
 * @link https://github.com/jaxon-php/jaxon-core
18
 */
19
20
namespace Jaxon\Traits;
21
22
use Jaxon\Utils\Container;
23
24
trait Autoload
25
{
26
    /**
27
     * Set Jaxon to use the Composer autoloader
28
     *
29
     * @return void
30
     */
31
    public function useComposerAutoloader()
32
    {
33
        $this->getPluginManager()->useComposerAutoloader();
0 ignored issues
show
Bug introduced by
It seems like getPluginManager() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
34
    }
35
36
    /**
37
     * Disable Jaxon classes autoloading
38
     *
39
     * @return void
40
     */
41
    public function disableAutoload()
42
    {
43
        $this->getPluginManager()->disableAutoload();
0 ignored issues
show
Bug introduced by
It seems like getPluginManager() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
44
    }
45
}
46