Skip to content

Commit

Permalink
Minor code quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
karllhughes committed Jul 24, 2015
1 parent ea5b8c3 commit a40a12a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
Expand Down
46 changes: 25 additions & 21 deletions src/Careerbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class Careerbuilder extends AbstractProvider
*
* @var string
*/
protected $enableCompanyCollapse;
protected $companyCollapse;

/**
* Returns the standardized job object
*
* @param array $payload
* @param array $payload Raw job payload from the API
*
* @return \JobBrander\Jobs\Client\Job
*/
public function createJobObject($payload)
public function createJobObject($payload = [])
{
$defaults = [
'Company',
Expand All @@ -64,7 +64,8 @@ public function createJobObject($payload)

$payload = static::parseAttributeDefaults($payload, $defaults);

$job = new Job([
$job = new Job(
[
'description' => $payload['DescriptionTeaser'],
'employmentType' => $payload['EmploymentType'],
'title' => $payload['JobTitle'],
Expand All @@ -75,7 +76,8 @@ public function createJobObject($payload)
'experienceRequirements' => $payload['ExperienceRequired'],
'minimumSalary' => $payload['Pay'],
'sourceId' => $payload['DID'],
]);
]
);

$job->setOccupationalCategoryWithCodeAndTitle(
$payload['OnetCode'],
Expand Down Expand Up @@ -118,7 +120,7 @@ public function getUseFacets()
*
* @return string
*/
public function getEnableCompanyCollapse()
public function getCompanyCollapse()
{
return 'true';
}
Expand All @@ -136,7 +138,7 @@ public function getFormat()
/**
* Get listings path
*
* @return string
* @return string
*/
public function getListingsPath()
{
Expand All @@ -146,7 +148,7 @@ public function getListingsPath()
/**
* Get parameters
*
* @return array
* @return array
*/
public function getParameters()
{
Expand All @@ -160,45 +162,47 @@ public function getParameters()
*/
public function getQueryString()
{
$query_params = [
$queryParams = [
'DeveloperKey' => 'getDeveloperKey',
'Keywords' => 'getKeyword',
'FacetState' => 'getState',
'FacetCity' => 'getCity',
'PageNumber' => 'getPage',
'PerPage' => 'getCount',
'UseFacets' => 'getUseFacets',
'EnableCompanyCollapse' => 'getEnableCompanyCollapse',
'EnableCompanyCollapse' => 'getCompanyCollapse',
];

$query_string = [];
$queryString = [];

array_walk($query_params, function ($value, $key) use (&$query_string) {
$computed_value = $this->$value();
if (!is_null($computed_value)) {
$query_string[$key] = $computed_value;
array_walk(
$queryParams, function ($value, $key) use (&$queryString) {
$computedValue = $this->$value();
if (!is_null($computedValue)) {
$queryString[$key] = $computedValue;
}
}
});
);

return http_build_query($query_string);
return http_build_query($queryString);
}

/**
* Get url
*
* @return string
* @return string
*/
public function getUrl()
{
$query_string = $this->getQueryString();
$queryString = $this->getQueryString();

return 'http://api.careerbuilder.com/v2/jobsearch/?'.$query_string;
return 'http://api.careerbuilder.com/v2/jobsearch/?'.$queryString;
}

/**
* Get http verb
*
* @return string
* @return string
*/
public function getVerb()
{
Expand Down

0 comments on commit a40a12a

Please sign in to comment.