-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 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
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
27
tests/Fixtures/Traits/Integers/TestIntegerDurationTrait.php
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,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; | ||
} |
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,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()); | ||
} | ||
} |