![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/framework/Magento/TestFramework/Helper/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** * Factory for helpers, used in Magento testing framework */ namespace Magento\TestFramework\Helper; class Factory { /** * @var array */ protected static $_instances = []; /** * Retrieves singleton instance of helper * * @param string $name * @return mixed */ public static function getHelper($name) { if (!isset(self::$_instances[$name])) { $className = preg_replace('/[^_]*$/', ucfirst($name), __CLASS__, 1); self::$_instances[$name] = new $className(); } return self::$_instances[$name]; } /** * Sets custom helper instance to be used for specific name, or null to clear instance. * Returns previous instance (if any) or null (if no helper was defined). * * @param string $name * @param mixed $helper * @return mixed */ public static function setHelper($name, $helper) { $old = isset(self::$_instances[$name]) ? self::$_instances[$name] : null; self::$_instances[$name] = $helper; return $old; } }