mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-23 11:29:00 +00:00
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Patch testing component for the Joomla! CMS
|
|
*
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
|
|
* @license GNU General Public License version 2 or later
|
|
*/
|
|
|
|
namespace PatchTester;
|
|
|
|
/**
|
|
* Helper class for Joomla's issue tracker integrations
|
|
*
|
|
* @since 2.0
|
|
*/
|
|
abstract class TrackerHelper
|
|
{
|
|
/**
|
|
* Array containing the supported repositories integrated with the Joomla! Issue Tracker
|
|
*
|
|
* @var array
|
|
* @since 2.0
|
|
*/
|
|
private static $projects = array(
|
|
'joomla-cms' => array(
|
|
'githubUser' => 'joomla',
|
|
'githubrepo' => 'joomla-cms',
|
|
'projectAlias' => 'joomla-cms',
|
|
),
|
|
'patchtester' => array(
|
|
'githubUser' => 'joomla-extensions',
|
|
'githubrepo' => 'patchtester',
|
|
'projectAlias' => 'patchtester',
|
|
),
|
|
'weblinks' => array(
|
|
'githubUser' => 'joomla-extensions',
|
|
'githubrepo' => 'weblinks',
|
|
'projectAlias' => 'weblinks',
|
|
),
|
|
);
|
|
|
|
/**
|
|
* Get the issue tracker project alias for a GitHub repository
|
|
*
|
|
* @param string $githubUser The owner of the GitHub repository (user or organization)
|
|
* @param string $githubRepo The GitHub repository name
|
|
*
|
|
* @return string|boolean The project alias if supported or boolean false
|
|
*
|
|
* @since 2.0
|
|
*/
|
|
public static function getTrackerAlias($githubUser, $githubRepo)
|
|
{
|
|
// If the repo isn't even listed, no point in going further
|
|
if (!array_key_exists($githubRepo, self::$projects))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Now the GitHub user must match the project (we don't support forks, sorry!)
|
|
if (self::$projects[$githubRepo]['githubUser'] !== $githubUser)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// This project is supported
|
|
return self::$projects[$githubRepo]['projectAlias'];
|
|
}
|
|
}
|