<?php namespace api\Sockets; class SocketManager { public static $Sockets; public static function Init() { self::$Sockets = []; } public static function AddSocket($socket) { self::$Sockets[] = $socket; } public static function CloseAllSockets() { foreach (self::$Sockets as $socket) { $socket->Close(); } } } SocketManager::Init();