File modules/util/ClassName.class.php

Last commit: Fri Dec 3 23:27:44 2021 +0100	dankert	New: Only allowed methods are shown in the dropdown menu; Some security enhancements.
1 <?php 2 3 4 namespace util; 5 6 7 class ClassName 8 { 9 protected $name; 10 11 /** 12 * ClassName constructor. 13 * @param $className object|string 14 */ 15 public function __construct($className ) { 16 17 if ( is_object( $className )) 18 $this->name = get_class( $className ); 19 else 20 $this->name = $className; 21 } 22 23 /** 24 * get full class name. 25 * @return string 26 */ 27 public function getName() 28 { 29 return $this->name; 30 } 31 32 33 public function dropNamespace() 34 { 35 if ( $pos = strrpos($this->name, '\\') ) 36 $this->name = substr($this->name, $pos + 1); 37 38 return $this; 39 } 40 41 public function addNamespace( $namespace ) 42 { 43 if ( ! is_array( $namespace) ) 44 $namespace = [ $namespace ]; 45 $this->name = implode('\\',$namespace ) . '\\' . $this->name; 46 47 return $this; 48 } 49 50 51 public function dropSuffix($suffix) 52 { 53 if ( substr($this->name,-strlen($suffix),strlen($suffix))) 54 $this->name = substr( $this->name,0,-(strlen($suffix)) ); 55 56 return $this; 57 } 58 59 60 public function get() 61 { 62 return $this->name; 63 } 64 65 66 public function getParent() { 67 $this->name = get_parent_class( $this->name ); 68 69 return $this; 70 } 71 72 73 public function exists() { 74 return $this->name !== FALSE && class_exists($this->name ); 75 } 76 }
Download modules/util/ClassName.class.php
History Fri, 3 Dec 2021 23:27:44 +0100 dankert New: Only allowed methods are shown in the dropdown menu; Some security enhancements. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.