Implemented hasClass

This commit is contained in:
Kevin Frantz 2019-02-03 13:13:11 +01:00
parent d00d70f440
commit 11d8ac9927
3 changed files with 15 additions and 0 deletions

View File

@ -36,4 +36,12 @@ trait ClassAttribut
{
return $this->class;
}
/**
* @return bool
*/
public function hasClass(): bool
{
return isset($this->class);
}
}

View File

@ -16,4 +16,9 @@ interface ClassAttributInterface
* @return string
*/
public function getClass(): string;
/**
* @return bool True if class is defined
*/
public function hasClass(): bool;
}

View File

@ -24,6 +24,7 @@ class ClassAttributTest extends TestCase
public function testConstructor(): void
{
$this->assertFalse($this->classAttribut->hasClass());
$this->expectException(\TypeError::class);
$this->classAttribut->getClass();
}
@ -32,6 +33,7 @@ class ClassAttributTest extends TestCase
{
$class = AbstractSource::class;
$this->assertNull($this->classAttribut->setClass($class));
$this->assertTrue($this->classAttribut->hasClass());
$this->assertEquals($class, $this->classAttribut->getClass());
}