|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Padosoft\AffiliateNetwork; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class AbstractNetwork |
|
7
|
|
|
* @package Padosoft\AffiliateNetwork |
|
8
|
|
|
*/ |
|
9
|
|
|
abstract class AbstractNetwork |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* username |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $username = ''; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* password |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $password = ''; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* AbstractNetwork constructor. |
|
25
|
|
|
* @param string $username |
|
26
|
|
|
* @param string $password |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(string $username, string $password) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->username = $username; |
|
31
|
|
|
$this->password = $password; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Call protected/private method of a class. |
|
36
|
|
|
* |
|
37
|
|
|
* @param object &$object Instantiated object that we will run method on. |
|
38
|
|
|
* @param string $methodName Method name to call |
|
39
|
|
|
* @param array $parameters Array of parameters to pass into method. |
|
40
|
|
|
* |
|
41
|
|
|
* @return mixed Method return. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function invokeMethod(&$object,$methodName, array $parameters = array()) |
|
44
|
|
|
{ |
|
45
|
|
|
$reflection = new \ReflectionClass(get_class($object)); |
|
46
|
|
|
$method = $reflection->getMethod($methodName); |
|
47
|
|
|
$method->setAccessible(true); |
|
48
|
|
|
return $method->invokeArgs($object, $parameters); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Call protected/private property of a class. |
|
53
|
|
|
* @param $object |
|
54
|
|
|
* @param $propertyName |
|
55
|
|
|
* |
|
56
|
|
|
* @return mixed |
|
57
|
|
|
*/ |
|
58
|
|
|
public function invokeProperty(&$object,$propertyName) |
|
59
|
|
|
{ |
|
60
|
|
|
$reflection = new \ReflectionClass(get_class($object)); |
|
61
|
|
|
$property = $reflection->getProperty($propertyName); |
|
62
|
|
|
$property->setAccessible(true); |
|
63
|
|
|
return $property->getValue($object); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|