How to use _getInstance method of name class

Best Mockery code snippet using name._getInstance

trace.php

Source:trace.php Github

copy

Full Screen

...78 */79 private function __construct() {}80 private function __clone() {}81 82 private static function _getInstance()83 {84 if(!self::$_instance)85 self::$_instance = new static();86 87 return self::$_instance;88 }89 90 /**91 * Test si on peu écrire un trace92 * @return bool 93 */94 private static function _canTrace()95 {96 if((TRACE || $_SESSION['SU']) && !self::$_noTrace)97 return true;98 else99 return false;100 }101 102 /**103 * Passe la variable static $_silent à true104 * @param void105 * @return void106 */107 public static function mute()108 {109 self::$_silent = true;110 }111 112 /**113 * Passe la variable static $_silent à true114 * @param void115 * @return void116 */117 public static function hide()118 {119 self::$_noTrace = true;120 }121 122 /**123 * Initialise la pile de messages si on est en débug124 */125 public static function init()126 {127 if(static::_canTrace())128 {129 self::_getInstance()->_iniTime = microtime();130 self::addTrace('Hello', 'Init', -2);131 }132 }133 134 /**135 * Ajoute 1 à la variable de benchmark des requètes136 * @param VOID137 * @return VOID138 */139 public static function addCount()140 {141 if(static::_canTrace())142 {143 self::_getInstance()->_queryCount++;144 }145 }146 147 /**148 * Ajoute un évènement dans la pile d'appel si on est en débug149 * @param string $msg150 * @param string $type151 * @param int $degre Colorisation de la ligne dans l'interface de bug152 */153 public static function addTrace($msg, $type, $degre = 0)154 {155 if(static::_canTrace())156 {157 $ist = microtime();158 self::_getInstance()->_trace[$ist]['type'] = $type;159 self::_getInstance()->_trace[$ist]['msg'] = $msg;160 self::_getInstance()->_trace[$ist]['degre'] = static::$_degreCode[$degre];161 self::_getInstance()->_trace[$ist]['time'] = self::_instant();162 self::_getInstance()->_trace[$ist]['ram'] = self::_getRam();163 164 if($type == 'He\Dispatch' || 165 $type == 'Dump' || 166 $type == 'Init')167 {168 self::_getInstance()->_traceDispatch[$ist] = &self::_getInstance()->_trace[$ist];169 }170 if($type == 'He\PDO' ||171 $type == 'He\PDOStatement' ||172 $type == 'Dump' || 173 $type == 'Init')174 {175 self::_getInstance()->_traceBdd[$ist] = &self::_getInstance()->_trace[$ist];176 }177 }178 }179 180 /**181 * Récupère le temps écoulé depuis l'initialisation de l'objet182 * ainsi que l'utilisation mémoire183 * @return string Message avec temps écoulé + RAM 184 */185 private static function _instant($fromTime = null, $toTime = null)186 {187 $refTime = (empty($fromTime) ? self::_getInstance()->_iniTime : $fromTime);188 $newTime = (empty($toTime) || empty($fromTime) ? microtime() : $toTime);189 190 /* on sépare les secondes et les millisecondes */191 list($micro1, $time1) = explode(' ', $refTime);192 list($micro2, $time2) = explode(' ', $newTime);193 194 /* on calcule le nombre de secondes qui séparent les 2 */195 $time = $time2 - $time1;196 197 /* On cast, au cas où */198 $micro1 = (FLOAT)$micro1;199 $micro2 = (FLOAT)$micro2;200 201 /* si le nombre de millisecondes du 1° temps est supérieur au 2°, 202 * C'est qu'il s'est écoulé au moins une seconde compète203 */204 if ($micro1 > $micro2)205 {206 $time--;207 $micro = 1.0 + $micro2 - $micro1;208 }209 /* sinon, on fait juste la différence */210 else211 {212 $micro = $micro2 - $micro1;213 }214 215 /* On fait la somme du temps transformé en float */216 return number_format(($micro + $time)* 1000, 0);217 }218 219 /**220 * Récupère la mémoire utilisé par le script221 * @return string222 */223 private static function _getRam()224 {225 $ram = number_format((memory_get_usage() / 1024 / 1024), 3);226 if($ram > self::_getInstance()->_maxRam)227 self::_getInstance()->_maxRam = $ram;228 229 return $ram;230 }231 232 /**233 * Affiche les évènements234 */235 public static function dump($echo = false)236 {237 /* Ajout de GoodBye*/238 self::addTrace('GoodBye', 'Dump', -2);239 self::mute();240 241 $hetrace = \He\Template::makeNode(ROOT.'/he/module/sutrace/template/trace.html');242 /* Alias */243 $hetrace = $hetrace->getNode('trace');244 245 /* Ajout de la pile d'appel générale */246 $prevMt = null;247 foreach(self::_getInstance()->_trace AS $mt => $varList)248 {249 $between = empty($prevMt) ? number_format(0, 5) : self::_instant($prevMt, $mt);250 $hetrace->bindVarListToNode($varList, 'traceTous');251 $hetrace->bindVarToNode('between', $between, 'traceTous');252 $hetrace->getNode('traceTous')->copy();253 $prevMt = $mt;254 }255 $hetrace->getNode('traceTous')->kill();256 257 /* Ajout de la pile d'appel bdd */258 $prevMt = null;259 foreach(self::_getInstance()->_traceBdd AS $mt => $varList)260 {261 $between = empty($prevMt) ? number_format(0, 5) : self::_instant($prevMt, $mt);262 $hetrace->bindVarListToNode($varList, 'traceBdd');263 $hetrace->bindVarToNode('between', $between, 'traceBdd');264 $hetrace->getNode('traceBdd')->copy();265 $prevMt = $mt;266 }267 $hetrace->getNode('traceBdd')->kill();268 269 /* Ajout de la pile d'appel Dispatcher */270 $prevMt = null;271 foreach(self::_getInstance()->_traceDispatch AS $mt => $varList)272 {273 $between = empty($prevMt) ? number_format(0, 5) : self::_instant($prevMt, $mt);274 $hetrace->bindVarListToNode($varList, 'traceDispatcher');275 $hetrace->bindVarToNode('between', $between, 'traceDispatcher');276 $hetrace->getNode('traceDispatcher')->copy();277 $prevMt = $mt;278 }279 $hetrace->getNode('traceDispatcher')->kill();280 281 /* Détail des variables en session */282 foreach($_SESSION as $name => $var)283 {284 $hetrace->bindVarToNode('name', $name, 'traceSession', true);285 $hetrace->bindVarToNode('value', static::var_dump($var), 'traceSession', true);286 $hetrace->getNode('traceSession')->copy();287 }288 $hetrace->getNode('traceSession')->kill();289 290 /* Détail des variables en cookies */291 foreach($_COOKIE as $name => $var)292 {293 $hetrace->bindVarToNode('name', $name, 'traceCookie', true);294 $hetrace->bindVarToNode('value', static::var_dump($var), 'traceCookie', true);295 $hetrace->getNode('traceCookie')->copy();296 }297 $hetrace->getNode('traceCookie')->kill();298 299 /* Ajout des benchs */300 $hetrace->bindVarToNode('queryCount', self::_getInstance()->_queryCount, 'bench');301 $hetrace->bindVarToNode('totalTime', self::_instant(self::_getInstance()->_iniTime, $mt), 'bench');302 $hetrace->bindVarToNode('maxRam', self::_getInstance()->_maxRam, 'bench');303 $hetrace->bindVarToNode('requestedUri', \He\Dispatch::getUri(), 'bench');304 305 $prev_trace = \He\DB::find('he_trace_log')->getMax();306 $hetrace->bindVarToNode('previd', $prev_trace, 'bench');307 $hetrace->bindVarToNode('id', $prev_trace + 1, 'bench');308 $hetrace->bindVarToNode('nextid', $prev_trace + 2, 'bench');309 310 /* Envoi */311 if(!self::$_noTrace)312 { 313 /* Log de la trace ~déplayé */314 \He\DB::he_trace_log()->setInstant('NOW()')315 ->setContent($hetrace->getContent())316 ->stor(true);...

Full Screen

Full Screen

Proxy.php

Source:Proxy.php Github

copy

Full Screen

...87 * Get the backing Zend_Acl instance.88 * This method will try to use a cached object first.89 * @return Zend_Acl90 */91 public function _getInstance()92 {93 if ($this->_instance === null) {94 if (empty($this->_className))95 throw new Fab_Acl_Exception('No backend ACL class name was specified');96 if ($this->_cache === null || ($acl = $this->_cache->load($this->_getCacheId())) === false) {97 $class = new ReflectionClass($this->_className);98 $acl = $class->getConstructor() == null ? $class->newInstance() : $class->newInstanceArgs($this->_classArgs);99 if ($this->_cache !== null) {100 $this->_cache->save($acl, $this->_getCacheId());101 }102 }103 $this->_instance = $acl;104 }105 return $this->_instance;106 }107 108 /* Overriden methods ******************************************************/109 public function __call($name, $arguments)110 {111 return call_user_func_array(array($this->_getInstance(), $name), $arguments);112 }113 114 public function add(Zend_Acl_Resource_Interface $resource, $parent = null)115 {116 return $this->_getInstance()->add($resource, $parent);117 }118 public function addResource($resource, $parent = null)119 {120 return $this->_getInstance()->addResource($resource, $parent);121 }122 public function addRole($role, $parents = null)123 {124 return $this->_getInstance()->addRole($role, $parents);125 }126 public function allow($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)127 {128 return $this->_getInstance()->allow($roles, $resources, $privileges, $assert);129 }130 public function deny($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)131 {132 return $this->_getInstance()->deny($roles, $resources, $privileges, $assert);133 }134 public function get($resource)135 {136 return $this->_getInstance()->get($resource);137 }138 public function getRegisteredRoles()139 {140 return $this->_getInstance()->getRegisteredRoles();141 }142 public function getResources()143 {144 return $this->_getInstance()->getResources();145 }146 public function getRole($role)147 {148 return $this->_getInstance()->getRole($role);149 }150 public function getRoles()151 {152 return $this->_getInstance()->getRoles();153 }154 public function has($resource)155 {156 return $this->_getInstance()->has($resource);157 }158 public function hasRole($role)159 {160 return $this->_getInstance()->hasRole($role);161 }162 public function inherits($resource, $inherit, $onlyParent = false)163 {164 return $this->_getInstance()->inherits($resource, $inherit, $onlyParent);165 }166 public function inheritsRole($role, $inherit, $onlyParents = false)167 {168 return $this->_getInstance()->inheritsRole($role, $inherit, $onlyParents);169 }170 public function isAllowed($role = null, $resource = null, $privilege = null)171 {172 return $this->_getInstance()->isAllowed($role, $resource, $privilege);173 }174 public function remove($resource)175 {176 return $this->_getInstance()->remove($resource);177 }178 public function removeAll()179 {180 return $this->_getInstance()->removeAll();181 }182 public function removeAllow($roles = null, $resources = null, $privileges = null)183 {184 return $this->_getInstance()->removeAllow($roles, $resources, $privileges);185 }186 public function removeDeny($roles = null, $resources = null, $privileges = null)187 {188 return $this->_getInstance()->removeDeny($roles, $resources, $privileges);189 }190 public function removeRole($role)191 {192 return $this->_getInstance()->removeRole($role);193 }194 public function removeRoleAll()195 {196 return $this->_getInstance()->removeRoleAll();197 }198 public function setRule($operation, $type, $roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)199 {200 return $this->_getInstance()->setRule($operation, $type, $roles, $resources, $privileges, $assert);201 }202}...

Full Screen

Full Screen

CopixHTMLHeader.class.php

Source:CopixHTMLHeader.class.php Github

copy

Full Screen

...14 var $_JSLink = array ();15 var $_JSCode = array ();16 var $_Others = array ();1718 function & _getInstance (){19 static $instance = false;20 if ($instance === false){21 $instance = new CopixHTMLHeader ();22 }23 return $instance;24 }25 26 function addJSLink ($src, $params=array()){27 $me = & CopixHTMLHeader::_getInstance ();28 if (!in_array ($src, $me->_JSLink)){29 $me->_JSLink[] = array ($src, $params);30 }31 }32 function addCSSLink ($src, $params=array ()){33 $me = & CopixHTMLHeader::_getInstance ();34 if (!in_array ($src, $me->_CSSLink)){35 $me->_CSSLink[] = array ($src, $params);36 }37 }38 function addStyle ($name, $def){39 $me = & CopixHTMLHeader::_getInstance ();40 if (!in_array ($name, array_keys ($me->_Styles))){41 $me->_Styles[$name] = $def;42 }43 }44 function addOthers ($content){45 $me = & CopixHTMLHeader::_getInstance ();46 $me->_Others[] = $content;47 }4849 function addJSCode ($code){50 $me = & CopixHTMLHeader::_getInstance ();51 $me->_JSCode[] = $code;52 }5354 function getOthers (){55 $me = & CopixHTMLHeader::_getInstance ();56 return implode ("\n\r", $me->_Others);57 }5859 function getJSCode (){60 $me = & CopixHTMLHeader::_getInstance ();61 if(($js= implode ("\n", $me->_JSCode)) != '')62 return '<script type="text/javascript"><!--63 '.$js.'64 //--></script>';65 else66 return '';67 }6869 function get (){70 $me = & CopixHTMLHeader::_getInstance ();71 return $me->getCSSLink () . "\n\r" . $me->getJSLink () . "\n\r" . $me->getStyles ()."\n\r" .$me->getJSCode ().$me->getOthers ();7273 }7475 function getStyles (){76 $me = & CopixHTMLHeader::_getInstance ();77 $built = array ();78 foreach ($me->_Styles as $name=>$value){79 if (strlen (trim($value))){80 //il y a une paire clef valeur.81 $built[] = $name.'{'.$value.'}';82 }else{83 //il n'y a pas de valeur, c'est peut être simplement une commande.84 //par exemple @import qqchose, ...85 $built[] = $name;86 }87 }88 if(($css=implode ("\n", $built)) != '')89 return '<style type="text/css"><!--90 '.$css.'91 //--></style>';92 else93 return '';94 }9596 function getCSSLink (){97 $built = array ();98 $me = & CopixHTMLHeader::_getInstance ();99 foreach ($me->_CSSLink as $elems){100 //the extra params we may found in there.101 $more = '';102 foreach ($elems[1] as $param_name=>$param_value){103 $more .= $param_name.'="'.$param_value.'" ';104 }105 $built[] = '<link rel="stylesheet" type="text/css" href="'.$elems[0].'" '.$more.' />';106 }107 return implode ("\n\r", $built);108 }109110 function getJSLink (){111 $built = array ();112 $me = & CopixHTMLHeader::_getInstance ();113 foreach ($me->_JSLink as $elems){114 //the extra params we may found in there.115 $more = '';116 foreach ($elems[1] as $param_name=>$param_value){117 $more .= $param_name.'="'.$param_value.'" ';118 }119 $built[] = '<script type="text/javascript" src="'.$elems[0].'" '.$more.'></script>';120 }121 return implode ("\n\r", $built);122 }123124 function clear ($what){125 $cleanable = array ('CSSLink', 'Styles', 'JSLink', 'JSCode', 'Others');126 foreach ($what as $elem){ ...

Full Screen

Full Screen

_getInstance

Using AI Code Generation

copy

Full Screen

1echo name::getInstance()->getName();2echo name::getInstance()->getName();3echo name::getInstance()->getName();4echo name::getInstance()->getName();5echo name::getInstance()->getName();6echo name::getInstance()->getName();7echo name::getInstance()->getName();8echo name::getInstance()->getName();9echo name::getInstance()->getName();10echo name::getInstance()->getName();11echo name::getInstance()->getName();12echo name::getInstance()->getName();13echo name::getInstance()->getName();14echo name::getInstance()->getName();15echo name::getInstance()->getName();16echo name::getInstance()->getName();17echo name::getInstance()->getName();18echo name::getInstance()->getName();19echo name::getInstance()->getName();20echo name::getInstance()->getName();

Full Screen

Full Screen

_getInstance

Using AI Code Generation

copy

Full Screen

1$name = name::getInstance();2echo $name->getName();3$name = name::getInstance();4echo $name->getName();5$name = name::getInstance();6echo $name->getName();7$name = name::getInstance();8echo $name->getName();

Full Screen

Full Screen

_getInstance

Using AI Code Generation

copy

Full Screen

1$object = name::_getInstance();2$object->method();3$object = name::_getInstance();4$object->method();5$object = name::_getInstance();6$object->method();7$object = name::_getInstance();8$object->method();9$object = name::_getInstance();10$object->method();11$object = name::_getInstance();12$object->method();13$object = name::_getInstance();14$object->method();15$object = name::_getInstance();16$object->method();17$object = name::_getInstance();18$object->method();19$object = name::_getInstance();20$object->method();21$object = name::_getInstance();22$object->method();23$object = name::_getInstance();24$object->method();25$object = name::_getInstance();26$object->method();27$object = name::_getInstance();28$object->method();29$object = name::_getInstance();30$object->method();31$object = name::_getInstance();32$object->method();33$object = name::_getInstance();34$object->method();

Full Screen

Full Screen

_getInstance

Using AI Code Generation

copy

Full Screen

1require_once('name.php');2$test = name::_getInstance();3require_once('name.php');4$test2 = name::_getInstance();5require_once('name.php');6$test3 = name::_getInstance();7require_once('name.php');8$test4 = name::_getInstance();9require_once('name.php');10$test5 = name::_getInstance();11require_once('name.php');12$test6 = name::_getInstance();13require_once('name.php');14$test7 = name::_getInstance();15require_once('name.php');16$test8 = name::_getInstance();17require_once('name.php');18$test9 = name::_getInstance();19require_once('name.php');20$test10 = name::_getInstance();21require_once('name.php');22$test11 = name::_getInstance();23require_once('name.php');24$test12 = name::_getInstance();25require_once('name.php');26$test13 = name::_getInstance();27require_once('name.php');28$test14 = name::_getInstance();29require_once('name.php');30$test15 = name::_getInstance();31require_once('name.php');32$test16 = name::_getInstance();33require_once('name.php');34$test17 = name::_getInstance();35require_once('name.php');36$test18 = name::_getInstance();37require_once('name.php');38$test19 = name::_getInstance();39require_once('name.php');40$test20 = name::_getInstance();

Full Screen

Full Screen

_getInstance

Using AI Code Generation

copy

Full Screen

1$object = Name::_getInstance('John','Doe');2$object->sayHello();3$object = Name::_getInstance('Jane','Doe');4$object->sayHello();5$object = Name::_getInstance('John','Doe');6$object->sayHello();7$object = Name::_getInstance('Jane','Doe');8$object->sayHello();9$object = Name::_getInstance('John','Doe');10$object->sayHello();11$object = Name::_getInstance('Jane','Doe');12$object->sayHello();13$object = Name::_getInstance('John','Doe');14$object->sayHello();15$object = Name::_getInstance('Jane','Doe');16$object->sayHello();17$object = Name::_getInstance('John','Doe');18$object->sayHello();19$object = Name::_getInstance('Jane','Doe');20$object->sayHello();21$object = Name::_getInstance('John','Doe');22$object->sayHello();23$object = Name::_getInstance('Jane','Doe');24$object->sayHello();25$object = Name::_getInstance('John','Doe');26$object->sayHello();27$object = Name::_getInstance('Jane','Doe');28$object->sayHello();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockery automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger _getInstance code on LambdaTest Cloud Grid

Execute automation tests with _getInstance on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful