Page MenuHomeDevCentral

D3216.id8238.diff
No OneTemporary

D3216.id8238.diff

diff --git a/omnitools/src/Reflection/CodeClass.php b/omnitools/src/Reflection/CodeClass.php
--- a/omnitools/src/Reflection/CodeClass.php
+++ b/omnitools/src/Reflection/CodeClass.php
@@ -21,6 +21,10 @@
) {
}
+ public static function from (object $object) : self {
+ return new self($object::class);
+ }
+
///
/// Class name helper methods
///
diff --git a/omnitools/tests/Reflection/CodeClassTest.php b/omnitools/tests/Reflection/CodeClassTest.php
--- a/omnitools/tests/Reflection/CodeClassTest.php
+++ b/omnitools/tests/Reflection/CodeClassTest.php
@@ -23,6 +23,14 @@
$this->class = new CodeClass(AcmeApplication::class);
}
+ public function testFrom () {
+ $date = new DateStamp(2010, 11, 25);
+ $class = CodeClass::from($date);
+
+ $this->assertInstanceOf(CodeClass::class, $class);
+ $this->assertEquals(DateStamp::class, $class->getClassName());
+ }
+
public function testGetClassName () {
$this->assertEquals(
AcmeApplication::class,

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 16:35 (19 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262673
Default Alt Text
D3216.id8238.diff (1 KB)

Event Timeline