Page MenuHomeDevCentral

D3215.id8233.diff
No OneTemporary

D3215.id8233.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,27 @@
) {
}
+ public static function from (object $object) : self {
+ return new self($object::class);
+ }
+
+ ///
+ /// Class name helper methods
+ ///
+
+ public function getClassName () : string {
+ return $this->className;
+ }
+
+ /**
+ * @throws ReflectionException
+ */
+ public function getShortClassName () : string {
+ $class = new ReflectionClass($this->className);
+
+ return $class->getShortName();
+ }
+
///
/// Represented class constructor 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,20 @@
$this->class = new CodeClass(AcmeApplication::class);
}
+ public function testGetClassName () {
+ $this->assertEquals(
+ AcmeApplication::class,
+ $this->class->getClassName(),
+ );
+ }
+
+ public function testGetShortClassName () {
+ $this->assertEquals(
+ "AcmeApplication",
+ $this->class->getShortClassName(),
+ );
+ }
+
public function testNewInstanceFromServices () {
$services = [
// Some objects (in different order than the constructor)
@@ -104,4 +118,5 @@
$class->getConstructor();
}
+
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 13:32 (15 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2387416
Default Alt Text
D3215.id8233.diff (1 KB)

Event Timeline