Skip to content

Commit

Permalink
Add integer duration trait
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Jun 4, 2024
1 parent 3d25482 commit 4867589
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/Traits/Integers/IntegerDurationTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
* This file is part of the core-library package.
*
* (c) 2024 WEBEWEB
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

namespace WBW\Library\Common\Traits\Integers;

/**
* Integer duration trait.
*
* @author webeweb <https://github.com/webeweb>
* @package WBW\Library\Common\Traits\Integers
*/
trait IntegerDurationTrait {

/**
* Duration.
*
* @var int|null
*/
protected $duration;

/**
* Get the duration.
*
* @return int|null Returns the duration.
*/
public function getDuration(): ?int {
return $this->duration;
}

/**
* Set the duration.
*
* @param int|null $duration The duration.
* @return self Returns this instance.
*/
public function setDuration(?int $duration): self {
$this->duration = $duration;
return $this;
}
}
27 changes: 27 additions & 0 deletions tests/Fixtures/Traits/Integers/TestIntegerDurationTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the core-library package.
*
* (c) 2024 WEBEWEB
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

namespace WBW\Library\Common\Tests\Fixtures\Traits\Integers;

use WBW\Library\Common\Traits\Integers\IntegerDurationTrait;

/**
* Test integer duration trait.
*
* @author webeweb <https://github.com/webeweb>
* @package WBW\Library\Common\Tests\Fixtures\Traits\Integers
*/
class TestIntegerDurationTrait {

use IntegerDurationTrait;
}
39 changes: 39 additions & 0 deletions tests/Traits/Integers/IntegerDurationTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the core-library package.
*
* (c) 2024 WEBEWEB
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

namespace WBW\Library\Common\Tests\Traits\Integers;

use WBW\Library\Common\Tests\AbstractTestCase;
use WBW\Library\Common\Tests\Fixtures\Traits\Integers\TestIntegerDurationTrait;

/**
* Integer duration trait test.
*
* @author webeweb <https://github.com/webeweb>
* @package WBW\Library\Common\Tests\Traits\Integers
*/
class IntegerDurationTraitTest extends AbstractTestCase {

/**
* Test setDuration()
*
* @return void
*/
public function testSetDuration(): void {

$obj = new TestIntegerDurationTrait();

$obj->setDuration(1);
$this->assertEquals(1, $obj->getDuration());
}
}

0 comments on commit 4867589

Please sign in to comment.