From 0e5929445b30f8bb3864e8dd4b327152e32b3601 Mon Sep 17 00:00:00 2001 From: Milan Popovic Date: Thu, 23 Jul 2015 11:21:55 +0200 Subject: [PATCH 1/2] Set default value --- src/DataContainer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataContainer.php b/src/DataContainer.php index 1af0103..b745868 100644 --- a/src/DataContainer.php +++ b/src/DataContainer.php @@ -12,7 +12,7 @@ class DataContainer extends Base /** * @var array $data */ - protected $data; + protected $data = []; /** * @var array $initialData From 04c6160137c040300b5ae43e5b591c14ebe721a1 Mon Sep 17 00:00:00 2001 From: Milan Popovic Date: Thu, 23 Jul 2015 11:22:24 +0200 Subject: [PATCH 2/2] Checking if element is array before going into loop --- src/AbstractImplementation.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/AbstractImplementation.php b/src/AbstractImplementation.php index 59c788a..cefd85b 100644 --- a/src/AbstractImplementation.php +++ b/src/AbstractImplementation.php @@ -21,8 +21,10 @@ abstract class AbstractImplementation extends DependencyHandler public function setUp(array $records = []) { if (empty($records)) { - foreach ($this->data as $collection => $rows) { - $records[$collection] = array_keys($rows); + if (is_array($this->data)){ + foreach ($this->data as $collection => $rows) { + $records[$collection] = array_keys($rows); + } } } elseif (SimpleArrayLibrary::countMaxDepth($records) == 1) { $this->validateCollections($records); @@ -66,8 +68,10 @@ public function setUp(array $records = []) public function tearDown(array $records = []) { if (empty($records)) { - foreach ($this->data as $collection => $rows) { - $records[$collection] = array_keys($rows); + if (is_array($this->data)) { + foreach ($this->data as $collection => $rows) { + $records[$collection] = array_keys($rows); + } } } elseif (SimpleArrayLibrary::countMaxDepth($records) == 1) { $this->validateCollections($records);