Skip to content

Commit

Permalink
Remove the unset capabilities of timeLimit. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmizzell authored Sep 13, 2019
1 parent 8318170 commit 3ee0118
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
16 changes: 16 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
plugins:
phpcodesniffer:
enabled: true
config:
standard: "PSR1,PSR2"
exclude_patterns:
- "**/*.yml"
- "**/*.json"
- "*.md"
- "**/*.md"
- "*.xml"
- "**/*.xml"
- ".circleci/"
- ".gitignore"

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
composer.lock
html
!.circleci
!.codeclimate.yml
9 changes: 3 additions & 6 deletions src/Job/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class Job implements \JsonSerializable
public function __construct()
{
$this->result = new Result(Result::STOPPED);
$this->timeLimit = PHP_INT_MAX;
}

public function run(): Result
Expand Down Expand Up @@ -49,14 +50,10 @@ public function run(): Result

abstract protected function runIt();

public function setTimeLimit(int $seconds)
public function setTimeLimit(int $seconds): bool
{
$this->timeLimit = $seconds;
}

public function unsetTimeLimit()
{
$this->timeLimit = null;
return true;
}

public function getTimeLimit()
Expand Down
5 changes: 1 addition & 4 deletions test/Job/JobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ public function testTimeLimit()
$timeLimit = 10;
$job = new Method($this, "callError");
$job->setTimeLimit($timeLimit);
$result = $job->run();
$job->run();
$this->assertEquals($timeLimit, $job->getTimeLimit());

$job->unsetTimeLimit();
$this->assertEquals(null, $job->getTimeLimit());
}

public function testReturn()
Expand Down

0 comments on commit 3ee0118

Please sign in to comment.