Skip to content

Commit

Permalink
Add string icon trait
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Aug 24, 2021
1 parent 569776a commit 589dff4
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/traits/Strings/StringIconTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

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

namespace WBW\Library\Traits\Strings;

/**
* String icon trait.
*
* @author webeweb <https://github.com/webeweb/>
* @package WBW\Library\Traits\Strings
*/
trait StringIconTrait {

/**
* Icon.
*
* @var string|null
*/
protected $icon;

/**
* Get the icon.
*
* @return string|null Returns the icon.
*/
public function getIcon(): ?string {
return $this->icon;
}

/**
* Set the icon.
*
* @param string|null $icon The icon.
* @return self Returns this instance.
*/
public function setIcon(?string $icon): self {
$this->icon = $icon;
return $this;
}
}
25 changes: 25 additions & 0 deletions tests/traits/Fixtures/Strings/TestStringIconTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

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

namespace WBW\Library\Traits\Tests\Fixtures\Strings;

use WBW\Library\Traits\Strings\StringIconTrait;

/**
* Test string icon trait.
*
* @author webeweb <https://github.com/webeweb/>
* @package WBW\Library\Traits\Tests\Fixtures\Strings
*/
class TestStringIconTrait {

use StringIconTrait;
}
37 changes: 37 additions & 0 deletions tests/traits/Strings/StringIconTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

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

namespace WBW\Library\Traits\Tests\Strings;

use WBW\Library\Traits\Tests\AbstractTestCase;
use WBW\Library\Traits\Tests\Fixtures\Strings\TestStringIconTrait;

/**
* String icon trait test.
*
* @author webeweb <https://github.com/webeweb/>
* @package WBW\Library\Traits\Tests\Strings
*/
class StringIconTraitTest extends AbstractTestCase {

/**
* Tests the setIcon() method.
*
* @return void
*/
public function testSetIcon(): void {

$obj = new TestStringIconTrait();

$obj->setIcon("icon");
$this->assertEquals("icon", $obj->getIcon());
}
}

0 comments on commit 589dff4

Please sign in to comment.