-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from neighborhoods/KOJO-151-state-transition-c…
…hange-model-code KOJO-151 | JobStateChange model code
- Loading branch information
Showing
55 changed files
with
1,426 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo; | ||
|
||
class JobStateChange implements JobStateChangeInterface | ||
{ | ||
/** @var int */ | ||
protected $id; | ||
/** @var JobStateChange\DataInterface */ | ||
protected $data; | ||
|
||
public function getId() : int | ||
{ | ||
if ($this->id === null) { | ||
throw new \LogicException('JobStateChange id has not been set.'); | ||
} | ||
return $this->id; | ||
} | ||
|
||
public function setId(int $id) : JobStateChangeInterface | ||
{ | ||
if ($this->id !== null) { | ||
throw new \LogicException('JobStateChange id is already set.'); | ||
} | ||
$this->id = $id; | ||
return $this; | ||
} | ||
|
||
public function getData() : JobStateChange\DataInterface | ||
{ | ||
if ($this->data === null) { | ||
throw new \LogicException('JobStateChange data has not been set.'); | ||
} | ||
return $this->data; | ||
} | ||
|
||
public function setData(JobStateChange\DataInterface $data) : JobStateChangeInterface | ||
{ | ||
if ($this->data !== null) { | ||
throw new \LogicException('JobStateChange data is already set.'); | ||
} | ||
$this->data = $data; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
neighborhoods.kojo.job_state_change: | ||
class: Neighborhoods\Kojo\JobStateChange | ||
public: false | ||
shared: false | ||
job_state_change: | ||
alias: neighborhoods.kojo.job_state_change | ||
public: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange; | ||
|
||
use Neighborhoods\Kojo\JobStateChangeInterface; | ||
|
||
/** @codeCoverageIgnore */ | ||
trait AwareTrait | ||
{ | ||
protected $NeighborhoodsKojoJobStateChange; | ||
|
||
public function setJobStateChange(JobStateChangeInterface $JobStateChange) : self | ||
{ | ||
if ($this->hasJobStateChange()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChange is already set.'); | ||
} | ||
$this->NeighborhoodsKojoJobStateChange = $JobStateChange; | ||
|
||
return $this; | ||
} | ||
|
||
protected function getJobStateChange() : JobStateChangeInterface | ||
{ | ||
if (!$this->hasJobStateChange()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChange is not set.'); | ||
} | ||
|
||
return $this->NeighborhoodsKojoJobStateChange; | ||
} | ||
|
||
protected function hasJobStateChange() : bool | ||
{ | ||
return isset($this->NeighborhoodsKojoJobStateChange); | ||
} | ||
|
||
protected function unsetJobStateChange() : self | ||
{ | ||
if (!$this->hasJobStateChange()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChange is not set.'); | ||
} | ||
unset($this->NeighborhoodsKojoJobStateChange); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange; | ||
|
||
use Neighborhoods\Kojo\JobStateChangeInterface; | ||
|
||
class Builder implements BuilderInterface | ||
{ | ||
use Factory\AwareTrait; | ||
use Data\Builder\Factory\AwareTrait; | ||
|
||
/** @var array */ | ||
protected $record; | ||
|
||
public function build() : JobStateChangeInterface | ||
{ | ||
$JobStateChange = $this->getJobStateChangeFactory()->create(); | ||
$record = $this->getRecord(); | ||
|
||
$JobStateChange->setId((int)$record[JobStateChangeInterface::PROP_ID]); | ||
$JobStateChange->setData( | ||
$this | ||
->getJobStateChangeDataBuilderFactory() | ||
->create() | ||
->setRecord($record[JobStateChangeInterface::PROP_DATA]) | ||
->build() | ||
); | ||
|
||
return $JobStateChange; | ||
} | ||
|
||
protected function getRecord() : array | ||
{ | ||
if ($this->record === null) { | ||
throw new \LogicException('Builder record has not been set.'); | ||
} | ||
|
||
return $this->record; | ||
} | ||
|
||
public function setRecord(array $record) : BuilderInterface | ||
{ | ||
if ($this->record !== null) { | ||
throw new \LogicException('Builder record is already set.'); | ||
} | ||
|
||
$this->record = $record; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
neighborhoods.kojo.job_state_change.builder: | ||
class: Neighborhoods\Kojo\JobStateChange\Builder | ||
public: false | ||
shared: false | ||
calls: | ||
- [setJobStateChangeFactory, ['@job_state_change.factory']] | ||
- [setJobStateChangeDataBuilderFactory, ['@job_state_change.data.builder.factory']] | ||
job_state_change.builder: | ||
alias: neighborhoods.kojo.job_state_change.builder | ||
public: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange\Builder; | ||
|
||
use Neighborhoods\Kojo\JobStateChange\BuilderInterface; | ||
|
||
/** @codeCoverageIgnore */ | ||
trait AwareTrait | ||
{ | ||
protected $NeighborhoodsKojoJobStateChangeBuilder; | ||
|
||
public function setJobStateChangeBuilder(BuilderInterface $JobStateChangeBuilder) : self | ||
{ | ||
if ($this->hasJobStateChangeBuilder()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChangeBuilder is already set.'); | ||
} | ||
$this->NeighborhoodsKojoJobStateChangeBuilder = $JobStateChangeBuilder; | ||
|
||
return $this; | ||
} | ||
|
||
protected function getJobStateChangeBuilder() : BuilderInterface | ||
{ | ||
if (!$this->hasJobStateChangeBuilder()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChangeBuilder is not set.'); | ||
} | ||
|
||
return $this->NeighborhoodsKojoJobStateChangeBuilder; | ||
} | ||
|
||
protected function hasJobStateChangeBuilder() : bool | ||
{ | ||
return isset($this->NeighborhoodsKojoJobStateChangeBuilder); | ||
} | ||
|
||
protected function unsetJobStateChangeBuilder() : self | ||
{ | ||
if (!$this->hasJobStateChangeBuilder()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChangeBuilder is not set.'); | ||
} | ||
unset($this->NeighborhoodsKojoJobStateChangeBuilder); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange\Builder; | ||
|
||
use Neighborhoods\Kojo\JobStateChange\BuilderInterface; | ||
|
||
/** @codeCoverageIgnore */ | ||
class Factory implements FactoryInterface | ||
{ | ||
use AwareTrait; | ||
|
||
public function create() : BuilderInterface | ||
{ | ||
return clone $this->getJobStateChangeBuilder(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
neighborhoods.kojo.job_state_change.builder.factory: | ||
class: Neighborhoods\Kojo\JobStateChange\Builder\Factory | ||
public: false | ||
shared: true | ||
calls: | ||
- [setJobStateChangeBuilder, ['@job_state_change.builder']] | ||
job_state_change.builder.factory: | ||
alias: neighborhoods.kojo.job_state_change.builder.factory | ||
public: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange\Builder\Factory; | ||
|
||
use Neighborhoods\Kojo\JobStateChange\Builder\FactoryInterface; | ||
|
||
/** @codeCoverageIgnore */ | ||
trait AwareTrait | ||
{ | ||
protected $NeighborhoodsKojoJobStateChangeBuilderFactory; | ||
|
||
public function setJobStateChangeBuilderFactory(FactoryInterface $JobStateChangeBuilderFactory) : self | ||
{ | ||
if ($this->hasJobStateChangeBuilderFactory()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChangeBuilderFactory is already set.'); | ||
} | ||
$this->NeighborhoodsKojoJobStateChangeBuilderFactory = $JobStateChangeBuilderFactory; | ||
|
||
return $this; | ||
} | ||
|
||
protected function getJobStateChangeBuilderFactory() : FactoryInterface | ||
{ | ||
if (!$this->hasJobStateChangeBuilderFactory()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChangeBuilderFactory is not set.'); | ||
} | ||
|
||
return $this->NeighborhoodsKojoJobStateChangeBuilderFactory; | ||
} | ||
|
||
protected function hasJobStateChangeBuilderFactory() : bool | ||
{ | ||
return isset($this->NeighborhoodsKojoJobStateChangeBuilderFactory); | ||
} | ||
|
||
protected function unsetJobStateChangeBuilderFactory() : self | ||
{ | ||
if (!$this->hasJobStateChangeBuilderFactory()) { | ||
throw new \LogicException('NeighborhoodsKojoJobStateChangeBuilderFactory is not set.'); | ||
} | ||
unset($this->NeighborhoodsKojoJobStateChangeBuilderFactory); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange\Builder; | ||
|
||
use Neighborhoods\Kojo\JobStateChange\BuilderInterface; | ||
|
||
/** @codeCoverageIgnore */ | ||
interface FactoryInterface | ||
{ | ||
public function create() : BuilderInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neighborhoods\Kojo\JobStateChange; | ||
|
||
use Neighborhoods\Kojo\JobStateChangeInterface; | ||
|
||
interface BuilderInterface | ||
{ | ||
public function build() : JobStateChangeInterface; | ||
|
||
public function setRecord(array $record) : BuilderInterface; | ||
} |
Oops, something went wrong.