-
Notifications
You must be signed in to change notification settings - Fork 1
/
HessianOptions.php
executable file
·76 lines (71 loc) · 1.88 KB
/
HessianOptions.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/*
* This file is part of the HessianPHP package.
* (c) 2004-2010 Manuel Gómez
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Configuration options for use in Hessian services, both client and server
*/
class HessianOptions{
public $version = 2;
/**
* Name of the transport to use
* @var string
*/
public $transport = 'CURL';
/**
* Array of custom options to pass to the transport object
* @var array
*/
public $transportOptions;
public $detectVersion = false;
public $objectFactory;
public $typeMap = array();
public $strictTypes = false;
public $headers = array();
public $interceptors = array();
public $timeZone;
public $saveRaw = false;
public $serviceName = '';
public $displayInfo = false;
public $ignoreOutput = false;
public $parseFilters = array();
public $writeFilters = array();
public $before = array();
public $after = array();
/**
* Takes an array and matches the corresponding properties in this object
* @param array $arr
*/
public function fromArray(array $arr){
$vars = get_class_vars('HessianOptions');
foreach($arr as $key=>$value){
if(array_key_exists($key, $vars)){
$this->$key = $value;
}
}
}
/**
* Tries to resolve a HessianOptions object from either an object or an array.
* Always return an options object
* @param mixed $object variable to resolve
* @return HessianOptions
*/
public static function resolveOptions($object){
$options = new HessianOptions();
if($object == null)
return $options;
if($object instanceof HessianOptions)
return $object;
elseif(is_array($object))
$options->fromArray($object);
elseif(is_object($object)){
$arr = (array)$object;
$options->fromArray($arr);
}
return $options;
}
}