@@ -53,7 +53,11 @@ class API
53
53
54
54
/**
55
55
* Constructor for the class,
56
- * send as many agument as you want.
56
+ * send as many argument as you want.
57
+ *
58
+ * No arguments - use file setup
59
+ * 1 argument - file to load config from
60
+ * 2 arguments - api key and api secret
57
61
*
58
62
* @return null
59
63
*/
@@ -62,106 +66,21 @@ public function __construct()
62
66
$ param = func_get_args ();
63
67
switch (func_num_args ()) {
64
68
case 0 :
65
- $ this ->__construct0 ();
69
+ $ this ->setupApiConfigFromFile ();
70
+ $ this ->setupProxyConfigFromFile ();
66
71
break ;
67
72
case 1 :
68
- $ this ->__construct1 ($ param [0 ]);
73
+ $ this ->setupApiConfigFromFile ($ param [0 ]);
74
+ $ this ->setupProxyConfigFromFile ($ param [0 ]);
75
+ $ this ->setupCurlOptsFromFile ($ param [0 ]);
69
76
break ;
70
77
case 2 :
71
- $ this ->__construct2 ($ param [0 ], $ param [1 ]);
72
- break ;
73
- case 3 :
74
- $ this ->__construct3 ($ param [0 ], $ param [1 ], $ param [2 ]);
75
- break ;
76
- case 4 :
77
- $ this ->__construct4 ($ param [0 ], $ param [1 ], $ param [2 ], $ param [3 ]);
78
+ $ this ->api_key = $ param [0 ];
79
+ $ this ->api_secret = $ param [1 ];
78
80
break ;
79
81
}
80
82
}
81
83
82
- /**
83
- * Constructor for the class
84
- *
85
- * @return null
86
- */
87
- private function __construct0 ()
88
- {
89
- $ this ->setupApiConfigFromFile ();
90
- $ this ->setupProxyConfigFromFile ();
91
- }
92
-
93
- /**
94
- * Constructor for the class
95
- * Specifiy the filename where the config is stored
96
- *
97
- * @param $filename string the config file location
98
- * @return null
99
- */
100
- private function __construct1 (string $ filename = null )
101
- {
102
- $ this ->setupApiConfigFromFile ($ filename );
103
- $ this ->setupProxyConfigFromFile ($ filename );
104
- $ this ->setupCurlOptsFromFile ($ filename );
105
- }
106
-
107
- /**
108
- * Constructor for the class
109
- *
110
- * @param $api_key string api key
111
- * @param $api_secret string api secret
112
- * @return null
113
- */
114
- private function __construct2 (string $ api_key = null , string $ api_secret = null )
115
- {
116
- $ this ->api_key = $ api_key ;
117
- $ this ->api_secret = $ api_secret ;
118
- }
119
-
120
- /**
121
- * Constructor for the class
122
- *
123
- * @param $api_key string api key
124
- * @param $api_secret string api secret
125
- * @param $options array addtional coniguration options
126
- * @return null
127
- */
128
- private function __construct3 (string $ api_key = null , string $ api_secret = null , array $ options = ["useServerTime " => false ])
129
- {
130
- $ this ->api_key = $ api_key ;
131
- $ this ->api_secret = $ api_secret ;
132
- if (isset ($ options ['useServerTime ' ]) && $ options ['useServerTime ' ]) {
133
- $ this ->useServerTime ();
134
- }
135
- if (isset ($ options ['curlOpts ' ]) && is_array ($ options ['curlOpts ' ])) {
136
- $ this ->curlOpts = $ options ['curlOpts ' ];
137
- }
138
- }
139
-
140
- /**
141
- * Constructor for the class
142
- *
143
- * @param $api_key string api key
144
- * @param $api_secret string api secret
145
- * @param $options array addtional coniguration options
146
- * @param $proxyConf array config
147
- * @return null
148
- */
149
- private function __construct4 (string $ api_key = null , string $ api_secret = null , array $ options = ["useServerTime " => false ], array $ proxyConf = null )
150
- {
151
- $ this ->api_key = $ api_key ;
152
- $ this ->api_secret = $ api_secret ;
153
- $ this ->proxyConf = $ proxyConf ;
154
- if (isset ($ options ['useServerTime ' ]) && $ options ['useServerTime ' ]) {
155
- $ this ->useServerTime ();
156
- }
157
- if (isset ($ options ['curlOpts ' ]) && is_array ($ options ['curlOpts ' ])) {
158
- $ this ->curlOpts = $ options ['curlOpts ' ];
159
- }
160
- $ this ->setupApiConfigFromFile ();
161
- $ this ->setupProxyConfigFromFile ();
162
- $ this ->setupCurlOptsFromFile ();
163
- }
164
-
165
84
/**
166
85
* magic get for private and protected members
167
86
*
0 commit comments