diff options
author | Arron Woods <aw@chartblocks.com> | 2015-04-10 17:38:36 +0100 |
---|---|---|
committer | Arron Woods <aw@chartblocks.com> | 2015-04-10 17:38:36 +0100 |
commit | 7335afb742d3a02710e3a8bfa5b78324f7837f39 (patch) | |
tree | 0d1e6d05630440b4a6132479acf6a59631b3edd3 | |
parent | d64de051345631de6d0733d86abbca0392bfe8ef (diff) | |
download | php-ssrs-7335afb742d3a02710e3a8bfa5b78324f7837f39.zip php-ssrs-7335afb742d3a02710e3a8bfa5b78324f7837f39.tar.gz php-ssrs-7335afb742d3a02710e3a8bfa5b78324f7837f39.tar.bz2 |
Fixes for empty results
-rwxr-xr-x | library/SSRS/Object/CatalogItems.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/library/SSRS/Object/CatalogItems.php b/library/SSRS/Object/CatalogItems.php index 6386cd5..22664f2 100755 --- a/library/SSRS/Object/CatalogItems.php +++ b/library/SSRS/Object/CatalogItems.php @@ -7,7 +7,7 @@ namespace SSRS\Object; * * @author arron */ -class CatalogItems extends ArrayIterator { +class CatalogItems extends ArrayIterator implements \Countable { public $iteratorKey = 'CatalogItems'; @@ -15,12 +15,29 @@ class CatalogItems extends ArrayIterator { $this->data['CatalogItems'] = array(); } + public function count() { + return count($this->data['CatalogItems']); + } + + /** + * + * @param \stdClass $items + * @return \SSRS\Object\CatalogItems + */ public function setCatalogItems(\stdClass $items) { - foreach ($items->CatalogItem AS $item) { - $this->addCatalogItem(new CatalogItem($item)); + if (isset($items->CatalogItem)) { + foreach ($items->CatalogItem AS $item) { + $this->addCatalogItem(new CatalogItem($item)); + } } + + return $this; } + /** + * + * @param \SSRS\Object\CatalogItem $item + */ public function addCatalogItem(CatalogItem $item) { $this->data['CatalogItems'][] = $item; } |