Back to HttpFactory class

Method getHttpTransports

public static array
getHttpTransports
()
Get the http transport handlers
Returns
  • array An array of available transport handlers
Since
  • 3.0.0
Class: HttpFactory
Project: Joomla

Method getHttpTransports - Source code

/**
 * Get the http transport handlers
 *
 * @return  array  An array of available transport handlers
 *
 * @since   3.0.0
 */
public static function getHttpTransports()
{
    $names = array();
    $iterator = new \DirectoryIterator(__DIR__ . '/Transport');
    /** @type  $file  \DirectoryIterator */
    foreach ($iterator as $file) {
        $fileName = $file->getFilename();
        // Only load for php files.
        if ($file->isFile() && $file->getExtension() === 'php') {
            $names[] = substr($fileName, 0, strrpos($fileName, 'Transport.'));
        }
    }
    // Keep alphabetical order across all environments
    sort($names);
    // If curl is available set it to the first position
    if ($key = array_search('Curl', $names)) {
        unset($names[$key]);
        array_unshift($names, 'Curl');
    }
    return $names;
}