Completed
Push — master ( 75c398...3c71f0 )
by Thierry
01:47
created

Request   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 6 1
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\Request\Factory\CallableObject;
16
17
use Jaxon\Request\Support\CallableObject;
18
19
class Request
20
{
21
    /**
22
     * The callable object this factory is attached to
23
     *
24
     * @var CallableObject
25
     */
26
    private $xCallable;
27
28
    /**
29
     * The class constructor
30
     *
31
     * @param CallableObject        $xCallable
32
     */
33
    public function __construct(CallableObject $xCallable)
34
    {
35
        $this->xCallable = $xCallable;
36
    }
37
38
    /**
39
     * Generate the corresponding javascript code for a call to any method
40
     *
41
     * @return string
42
     */
43
    public function __call($sMethod, $aArguments)
44
    {
45
        // Make the request
46
        $factory = rq()->setCallable($this->xCallable);
47
        return call_user_func_array([$factory, 'call'], array_merge([$sMethod], $aArguments));
48
    }
49
}
50