Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/yandex.market/lib/result/ |
Upload File : |
<?php namespace Yandex\Market\Result; use Bitrix\Main; class Pool { protected static $instances = []; protected $className; protected $free = []; /** * @param class-string<Base|Main\Result> $className * * @return static */ public static function getInstance($className = Base::class) { if (!isset(static::$instances[$className])) { static::$instances[$className] = new static($className); } return static::$instances[$className]; } /** @param class-string<Base|Main\Result> $className */ public function __construct($className) { $this->className = $className; } /** @return Base|Main\Result */ public function get() { $result = array_pop($this->free); if ($result === null || !$result->isSuccess()) { $result = new $this->className; } return $result; } /** @param Base|Main\Result $result */ public function release($result) { if (!$result->isSuccess()) { return; } $this->free[] = $result; } }