Skip to content

Commit

Permalink
Merge pull request #482 from tienvx/remove-timestampable-trait
Browse files Browse the repository at this point in the history
Remove timestampable trait
  • Loading branch information
tienvx committed May 19, 2020
2 parents 52d2da6 + 41842bb commit 7d30fc4
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: PHP Insights
uses: docker://tienvx/phpinsights-action
with:
args: "-v --config-path=insights.php --min-quality=80 --min-complexity=80 --min-architecture=80 --min-style=90"
args: "-v --config-path=insights.php --min-quality=80 --min-complexity=80 --min-architecture=70 --min-style=90"

test:
name: Test PHP ${{ matrix.php }}
Expand Down
3 changes: 0 additions & 3 deletions insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
// ExampleInsight::class,
\PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff::class,
\NunoMaduro\PhpInsights\Domain\Insights\ForbiddenNormalClasses::class,
\NunoMaduro\PhpInsights\Domain\Insights\ForbiddenTraits::class,
\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneTraitPerFileSniff::class,
\SlevomatCodingStandard\Sniffs\Classes\SuperfluousTraitNamingSniff::class,
\SlevomatCodingStandard\Sniffs\Classes\SuperfluousInterfaceNamingSniff::class,
\SlevomatCodingStandard\Sniffs\Classes\SuperfluousAbstractClassNamingSniff::class,
],
Expand Down
30 changes: 28 additions & 2 deletions src/Entity/Bug.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tienvx\Bundle\MbtBundle\Entity;

use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Tienvx\Bundle\MbtBundle\Model\Bug as BugModel;
Expand All @@ -14,8 +15,6 @@
*/
class Bug extends BugModel
{
use TimestampableTrait;

/**
* @ORM\Column(type="integer")
* @ORM\Id()
Expand Down Expand Up @@ -77,8 +76,35 @@ class Bug extends BugModel
*/
protected $messagesCount = 0;

/**
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
protected $createdAt;

/**
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
protected $updatedAt;

public function getWorkflow(): WorkflowInterface
{
return new Workflow($this->workflow);
}

/**
* @ORM\PrePersist
*/
public function prePersist(): void
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
}

/**
* @ORM\PreUpdate
*/
public function preUpdate(): void
{
$this->updatedAt = new DateTime();
}
}
29 changes: 27 additions & 2 deletions src/Entity/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tienvx\Bundle\MbtBundle\Entity;

use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Tienvx\Bundle\MbtBundle\Model\GeneratorInterface;
Expand All @@ -17,8 +18,6 @@
*/
class Task extends TaskModel
{
use TimestampableTrait;

/**
* @ORM\Column(type="integer")
* @ORM\Id()
Expand Down Expand Up @@ -87,6 +86,15 @@ class Task extends TaskModel
* @Assert\Type("bool")
*/
protected $takeScreenshots;
/**
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
protected $createdAt;

/**
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
protected $updatedAt;

public function __construct()
{
Expand Down Expand Up @@ -121,4 +129,21 @@ public function getReducer(): ReducerInterface
{
return new Reducer($this->reducer);
}

/**
* @ORM\PrePersist
*/
public function prePersist(): void
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
}

/**
* @ORM\PreUpdate
*/
public function preUpdate(): void
{
$this->updatedAt = new DateTime();
}
}
36 changes: 0 additions & 36 deletions src/Entity/TimestampableTrait.php

This file was deleted.

37 changes: 35 additions & 2 deletions src/Model/Bug.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Tienvx\Bundle\MbtBundle\Model;

use DateTimeInterface;
use Tienvx\Bundle\MbtBundle\Steps\Steps;
use Tienvx\Bundle\MbtBundle\Workflow\BugWorkflow;

class Bug implements BugInterface
{
use TimestampableTrait;

/**
* @var int|null
*/
Expand Down Expand Up @@ -54,6 +53,16 @@ class Bug implements BugInterface
*/
protected $messagesCount = 0;

/**
* @var ?DateTimeInterface
*/
protected $updatedAt;

/**
* @var ?DateTimeInterface
*/
protected $createdAt;

public function __construct()
{
$this->status = BugWorkflow::NEW;
Expand Down Expand Up @@ -159,4 +168,28 @@ public function setMessagesCount(int $messagesCount): BugInterface

return $this;
}

public function setCreatedAt(DateTimeInterface $createdAt): BugInterface
{
$this->createdAt = $createdAt;

return $this;
}

public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}

public function setUpdatedAt(DateTimeInterface $updatedAt): BugInterface
{
$this->updatedAt = $updatedAt;

return $this;
}

public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
}
4 changes: 2 additions & 2 deletions src/Model/BugInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public function getMessagesCount(): int;

public function setMessagesCount(int $messagesCount): self;

public function setCreatedAt(DateTimeInterface $createdAt): void;
public function setCreatedAt(DateTimeInterface $createdAt): self;

public function getCreatedAt(): ?DateTimeInterface;

public function setUpdatedAt(DateTimeInterface $updatedAt): void;
public function setUpdatedAt(DateTimeInterface $updatedAt): self;

public function getUpdatedAt(): ?DateTimeInterface;
}
37 changes: 35 additions & 2 deletions src/Model/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace Tienvx\Bundle\MbtBundle\Model;

use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Tienvx\Bundle\MbtBundle\Workflow\TaskWorkflow;

class Task implements TaskInterface
{
use TimestampableTrait;

/**
* @var int|null
*/
Expand Down Expand Up @@ -60,6 +59,16 @@ class Task implements TaskInterface
*/
protected $takeScreenshots;

/**
* @var ?DateTimeInterface
*/
protected $updatedAt;

/**
* @var ?DateTimeInterface
*/
protected $createdAt;

public function __construct()
{
$this->bugs = new ArrayCollection();
Expand Down Expand Up @@ -201,4 +210,28 @@ public function getTakeScreenshots(): bool
{
return $this->takeScreenshots;
}

public function setCreatedAt(DateTimeInterface $createdAt): TaskInterface
{
$this->createdAt = $createdAt;

return $this;
}

public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}

public function setUpdatedAt(DateTimeInterface $updatedAt): TaskInterface
{
$this->updatedAt = $updatedAt;

return $this;
}

public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
}
4 changes: 2 additions & 2 deletions src/Model/TaskInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public function getTakeScreenshots(): bool;

public function setTakeScreenshots(bool $takeScreenshots): self;

public function setCreatedAt(DateTimeInterface $createdAt): void;
public function setCreatedAt(DateTimeInterface $createdAt): self;

public function getCreatedAt(): ?DateTimeInterface;

public function setUpdatedAt(DateTimeInterface $updatedAt): void;
public function setUpdatedAt(DateTimeInterface $updatedAt): self;

public function getUpdatedAt(): ?DateTimeInterface;
}
38 changes: 0 additions & 38 deletions src/Model/TimestampableTrait.php

This file was deleted.

0 comments on commit 7d30fc4

Please sign in to comment.