![]() Server : LiteSpeed System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 User : claqxcrl ( 523) PHP Version : 8.1.32 Disable Function : NONE Directory : /home/claqxcrl/anfangola.com/wp-content/plugins/matomo/app/core/ |
<?php /** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * */ namespace Piwik; use Exception; /** * Base class for all factory types. * * Factory types are base classes that contain a **factory** method. This method is used to instantiate * concrete instances by a specified string ID. Fatal errors do not occur if a class does not exist. * Instead an exception is thrown. * * Derived classes should override the **getClassNameFromClassId** and **getInvalidClassIdExceptionMessage** * static methods. */ abstract class BaseFactory { /** * Creates a new instance of a class using a string ID. * * @param string $classId The ID of the class. * @return \Piwik\DataTable\Renderer * @throws Exception if $classId is invalid. */ public static function factory($classId) { $className = static::getClassNameFromClassId($classId); if (!class_exists($className)) { self::sendPlainHeader(); throw new Exception(static::getInvalidClassIdExceptionMessage($classId)); } return new $className(); } private static function sendPlainHeader() { \Piwik\Common::sendHeader('Content-Type: text/plain; charset=utf-8'); } /** * Should return a class name based on the class's associated string ID. */ protected static function getClassNameFromClassId($id) { return $id; } /** * Should return a message to use in an Exception when an invalid class ID is supplied to * {@link factory()}. */ protected static function getInvalidClassIdExceptionMessage($id) { return "Invalid class ID '{$id}' for " . get_called_class() . "::factory()."; } }