Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #45 from hpyzik/#44
Browse files Browse the repository at this point in the history
Add getters to FindBySectionParameters #44
  • Loading branch information
hpyzik authored Jun 20, 2017
2 parents 77ec4f4 + a19bdf9 commit cabdd47
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
48 changes: 48 additions & 0 deletions spec/Snt/Capi/Repository/Article/FindBySectionParametersSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,52 @@ function it_throws_exception_when_dates_are_incorrect()
$this->shouldThrow(InvalidArgumentException::class)->duringSetHotnessTo(120);
$this->shouldThrow(InvalidArgumentException::class)->duringSetView('invalid-view');
}

function it_returns_parameters()
{
$view = FindBySectionParameters::VIEW_ENTIRE;
$offset = 80;
$limit = 40;
$since = '2014-12-07';
$until = '2017-01-05';
$hotnessFrom = 10;
$hotnessTo = 30;
$lifetimeFrom = 40;
$lifetimeTo = 50;

$this->setView($view);
$this->setOffset($offset);
$this->setLimit($limit);
$this->setSince($since);
$this->setUntil($until);
$this->setHotnessFrom($hotnessFrom);
$this->setHotnessTo($hotnessTo);
$this->setLifetimeFrom($lifetimeFrom);
$this->setLifetimeTo($lifetimeTo);

$this->getPublicationId()->shouldReturn(self::PUBLICATION_ID);
$this->getSections()->shouldReturn([self::SECTION_NAME]);
$this->getView()->shouldReturn($view);
$this->getOffset()->shouldReturn($offset);
$this->getLimit()->shouldReturn($limit);
$this->getSince()->shouldReturn($since);
$this->getUntil()->shouldReturn($until);
$this->getHotnessFrom()->shouldReturn($hotnessFrom);
$this->getHotnessTo()->shouldReturn($hotnessTo);
$this->getLifetimeFrom()->shouldReturn($lifetimeFrom);
$this->getLifetimeTo()->shouldReturn($lifetimeTo);
}

function it_returns_nulls_when_parameters_are_not_set()
{
$this->getView()->shouldReturn(null);
$this->getOffset()->shouldReturn(null);
$this->getLimit()->shouldReturn(null);
$this->getSince()->shouldReturn(null);
$this->getUntil()->shouldReturn(null);
$this->getHotnessFrom()->shouldReturn(null);
$this->getHotnessTo()->shouldReturn(null);
$this->getLifetimeFrom()->shouldReturn(null);
$this->getLifetimeTo()->shouldReturn(null);
}
}
88 changes: 88 additions & 0 deletions src/Snt/Capi/Repository/Article/FindBySectionParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ public function buildApiHttpPathAndQuery()
return ApiHttpPathAndQuery::createForPathAndQuery($path, $query);
}

/**
* @return string
*/
public function getPublicationId()
{
return $this->publicationId;
}

/**
* @return array|string[]
*/
public function getSections()
{
return $this->sections;
}

/**
* @param string $view
*
Expand All @@ -86,6 +102,14 @@ public function setView($view)
return $this;
}

/**
* @return string|null
*/
public function getView()
{
return isset($this->parameters['view']) ? $this->parameters['view'] : null;
}

/**
* @param int $offset
*
Expand All @@ -98,6 +122,14 @@ public function setOffset($offset)
return $this;
}

/**
* @return int|null
*/
public function getOffset()
{
return isset($this->parameters['offset']) ? $this->parameters['offset'] : null;
}

/**
* @param int $limit
*
Expand All @@ -110,6 +142,14 @@ public function setLimit($limit)
return $this;
}

/**
* @return int|null
*/
public function getLimit()
{
return isset($this->parameters['limit']) ? $this->parameters['limit'] : null;
}

/**
* @param string $since
*
Expand All @@ -128,6 +168,14 @@ public function setSince($since)
return $this;
}

/**
* @return string|null
*/
public function getSince()
{
return isset($this->parameters['since']) ? $this->parameters['since'] : null;
}

/**
* @param string $until
*
Expand All @@ -146,6 +194,14 @@ public function setUntil($until)
return $this;
}

/**
* @return string|null
*/
public function getUntil()
{
return isset($this->parameters['until']) ? $this->parameters['until'] : null;
}

/**
* @param int $hotnessFrom
*
Expand All @@ -164,6 +220,14 @@ public function setHotnessFrom($hotnessFrom)
return $this;
}

/**
* @return int|null
*/
public function getHotnessFrom()
{
return isset($this->parameters['hotnessFrom']) ? $this->parameters['hotnessFrom'] : null;
}

/**
* @param int $hotnessTo
*
Expand All @@ -182,6 +246,14 @@ public function setHotnessTo($hotnessTo)
return $this;
}

/**
* @return int|null
*/
public function getHotnessTo()
{
return isset($this->parameters['hotnessTo']) ? $this->parameters['hotnessTo'] : null;
}

/**
* @param int $lifetimeFrom
*
Expand All @@ -200,6 +272,14 @@ public function setLifetimeFrom($lifetimeFrom)
return $this;
}

/**
* @return int|null
*/
public function getLifetimeFrom()
{
return isset($this->parameters['lifetimeFrom']) ? $this->parameters['lifetimeFrom'] : null;
}

/**
* @param int $lifetimeTo
*
Expand All @@ -218,6 +298,14 @@ public function setLifetimeTo($lifetimeTo)
return $this;
}

/**
* @return int|null
*/
public function getLifetimeTo()
{
return isset($this->parameters['lifetimeTo']) ? $this->parameters['lifetimeTo'] : null;
}

/**
* @param int $value
*
Expand Down

0 comments on commit cabdd47

Please sign in to comment.