forked from chopin2256/Amazon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAmazon.php
38 lines (30 loc) · 1.04 KB
/
Amazon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once('Amazon/Amazon_Base.php');
require_once('Amazon/Amazon_Config.php');
require_once('Amazon/Amazon_Get.php');
require_once('Amazon/Interfaces/I_Amazon.php');
class Amazon extends Amazon_Base implements I_Amazon {
public function config() {
return new Amazon_Config();
}
public function search($kw) {
//Reflection, keeping _init hidden
$class = new ReflectionClass(new Amazon_Base());
$newClass = $class->getMethod("_init");
$newClass->setAccessible(true);
$newClass->invoke(new Amazon_Base(), $kw);
}
public function get() {
return new Amazon_Get();
}
public function clear() {
//Set private value _arrayData = null and _counter = 0 through reflection
$privateVals = array("_arrayData" => null, "_counter" => 0);
foreach ($privateVals as $k => $v) {
$class = new ReflectionProperty(new Amazon_Base(), $k);
$class->setAccessible(true);
$class->setValue(new Amazon_Base(), $v);
}
}
}
?>