Completed
Push — master ( fd24d6...d99eda )
by Thierry
02:33
created

Portable::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Factory.php - Jaxon Request Factory
5
 *
6
 * Create Jaxon client side requests to a given class.
7
 *
8
 * @package jaxon-core
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-core
13
 */
14
15
namespace Jaxon\Factory\CallableObject;
16
17
use Jaxon\DI\Container;
18
use Jaxon\Request\Support\CallableObject;
19
20
class Portable
21
{
22
    /**
23
     * The callable object this factory is attached to
24
     *
25
     * @var CallableObject
26
     */
27
    private $xCallable;
28
29
    /**
30
     * Create a new Factory instance.
31
     *
32
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
33
     */
34
    public function __construct(CallableObject $xCallable)
35
    {
36
        $this->xCallable = $xCallable;
37
    }
38
39
    /**
40
     * Generate the corresponding javascript code for a call to any method
41
     *
42
     * @return string
43
     */
44
    public function __call($sMethod, $aArguments)
45
    {
46
        // Make the request
47
        $factory = Container::getInstance()->getRequestFactory()->setCallable($this->xCallable);
48
        return call_user_func_array([$factory, 'call'], array_merge([$sMethod], $aArguments));
49
    }
50
}
51