Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3775079
D3216.id8238.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D3216.id8238.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D3216: Build a new instance from CodeClass from an existing object
Attached
Detach File
Event Timeline
Log In to Comment