Skip to content

Commit

Permalink
Fixing bug in abstract provider
Browse files Browse the repository at this point in the history
  • Loading branch information
karllhughes committed Jan 21, 2017
1 parent 1f4e1a2 commit e35bf88
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All Notable changes to `jobs-common` will be documented in this file

## 2.1.2 - 2017-01-21

### Fixed
- Fixed bug that threw an exception for some providers when empty results were returned from the API.

## 2.1.1 - 2016-12-23

### Fixed
Expand Down
31 changes: 23 additions & 8 deletions src/Providers/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,15 @@ public function setQuery(AbstractQuery $query)
}

/**
* Create and get collection of jobs from given listings
* Adds a single job item to a collection (passed by reference)
*
* @param array $listings
* @param $collection Collection
* @param $item array
*
* @return Collection
* @return $collection
*/
protected function getJobsCollectionFromListings(array $listings = [])
{
$collection = new Collection;

array_map(function ($item) use ($collection) {
protected function addJobItemToCollection(&$collection, $item = []) {
if ($item) {
$item = static::parseAttributeDefaults(
$item,
$this->getDefaultResponseFields()
Expand All @@ -210,6 +208,23 @@ protected function getJobsCollectionFromListings(array $listings = [])
$job->setQuery($this->query->getKeyword())
->setSource($this->getSource());
$collection->add($job);
}
return $collection;
}

/**
* Create and get collection of jobs from given listings
*
* @param array $listings
*
* @return Collection
*/
protected function getJobsCollectionFromListings(array $listings = [])
{
$collection = new Collection;

array_map(function ($item) use ($collection) {
$this->addJobItemToCollection($collection, $item);
}, $listings);

return $collection;
Expand Down

0 comments on commit e35bf88

Please sign in to comment.