Skip to content

Commit feed8d8

Browse files
committed
Started implementing null checks and error checks.
WIP.
1 parent b5a3e0f commit feed8d8

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

source/TraderTrait.php

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ private static function checkForError()
141141
*/
142142
public static function acos(array $real): array
143143
{
144-
return trader_acos($real);
144+
$return = trader_acos($real);
145+
static::checkForError();
146+
147+
return $return;
145148
}
146149

147150
/**
@@ -186,7 +189,14 @@ public static function add(array $real0, array $real1): array
186189
*/
187190
public static function adosc(array $high, array $low, array $close, array $volume, integer $fastPeriod = null, integer $slowPeriod = null): array
188191
{
189-
return trader_adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod);
192+
if (!is_null($slowPeriod)) {
193+
return trader_adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod);
194+
}
195+
if (!is_null($fastPeriod)) {
196+
return trader_adosc($high, $low, $close, $volume, $fastPeriod);
197+
}
198+
199+
return trader_adosc($high, $low, $close, $volume);
190200
}
191201

192202
/**
@@ -201,7 +211,11 @@ public static function adosc(array $high, array $low, array $close, array $volum
201211
*/
202212
public static function adx(array $high, array $low, array $close, integer $timePeriod = null): array
203213
{
204-
return trader_adx($high, $low, $close, $timePeriod);
214+
if (!is_null($timePeriod)) {
215+
return trader_adx($high, $low, $close, $timePeriod);
216+
}
217+
218+
return trader_adx($high, $low, $close);
205219
}
206220

207221
/**
@@ -216,7 +230,11 @@ public static function adx(array $high, array $low, array $close, integer $timeP
216230
*/
217231
public static function adxr(array $high, array $low, array $close, integer $timePeriod = null): array
218232
{
219-
return trader_adxr($high, $low, $close, $timePeriod);
233+
if (!is_null($timePeriod)) {
234+
return trader_adxr($high, $low, $close, $timePeriod);
235+
}
236+
237+
return trader_adxr($high, $low, $close);
220238
}
221239

222240
/**
@@ -231,7 +249,17 @@ public static function adxr(array $high, array $low, array $close, integer $time
231249
*/
232250
public static function apo(array $real, integer $fastPeriod = null, integer $slowPeriod = null, integer $mAType = null): array
233251
{
234-
return trader_apo($real, $fastPeriod, $slowPeriod, $mAType);
252+
if (!is_null($mAType)) {
253+
return trader_apo($real, $fastPeriod, $slowPeriod, $mAType);
254+
}
255+
if (!is_null($slowPeriod)) {
256+
return trader_apo($real, $fastPeriod, $slowPeriod);
257+
}
258+
if (!is_null($fastPeriod)) {
259+
return trader_apo($real, $fastPeriod);
260+
}
261+
262+
return trader_apo($real);
235263
}
236264

237265
/**
@@ -245,7 +273,11 @@ public static function apo(array $real, integer $fastPeriod = null, integer $slo
245273
*/
246274
public static function aroon(array $high, array $low, integer $timePeriod = null): array
247275
{
248-
return trader_aroon($high, $low, $timePeriod);
276+
if (!is_null($timePeriod)) {
277+
return trader_aroon($high, $low, $timePeriod);
278+
}
279+
280+
return trader_aroon($high, $low);
249281
}
250282

251283
/**
@@ -259,7 +291,11 @@ public static function aroon(array $high, array $low, integer $timePeriod = null
259291
*/
260292
public static function arronosc(array $high, array $low, integer $timePeriod = null): array
261293
{
262-
return trader_aroonosc($high, $low, $timePeriod);
294+
if (!is_null($timePeriod)) {
295+
return trader_aroonosc($high, $low, $timePeriod);
296+
}
297+
298+
return trader_aroonosc($high, $low);
263299
}
264300

265301
/**

0 commit comments

Comments
 (0)