diff --git a/src/MBO/RemoteGit/ClientFactory.php b/src/MBO/RemoteGit/ClientFactory.php index 616d320..90d4d5e 100644 --- a/src/MBO/RemoteGit/ClientFactory.php +++ b/src/MBO/RemoteGit/ClientFactory.php @@ -5,6 +5,10 @@ use Psr\Log\LoggerInterface; use \GuzzleHttp\Client as GuzzleHttpClient; +use MBO\RemoteGit\Github\GithubClient; +use MBO\RemoteGit\Gitlab\GitlabClient; + + /** * Helper to create clients */ diff --git a/src/MBO/RemoteGit/Filter/FilterCollection.php b/src/MBO/RemoteGit/Filter/FilterCollection.php index b642de5..97c3496 100644 --- a/src/MBO/RemoteGit/Filter/FilterCollection.php +++ b/src/MBO/RemoteGit/Filter/FilterCollection.php @@ -4,7 +4,9 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; + use MBO\RemoteGit\ProjectInterface; +use MBO\RemoteGit\ProjectFilterInterface; /** * Compose a list of filter to simplify command line integration diff --git a/src/MBO/RemoteGit/Filter/GitlabNamespaceFilter.php b/src/MBO/RemoteGit/Filter/GitlabNamespaceFilter.php index cf54e9f..a45c914 100644 --- a/src/MBO/RemoteGit/Filter/GitlabNamespaceFilter.php +++ b/src/MBO/RemoteGit/Filter/GitlabNamespaceFilter.php @@ -2,9 +2,11 @@ namespace MBO\RemoteGit\Filter; +use Psr\Log\LoggerInterface; + use MBO\RemoteGit\ProjectInterface; +use MBO\RemoteGit\ProjectFilterInterface; use MBO\RemoteGit\ClientInterface as GitClientInterface; -use Psr\Log\LoggerInterface; /** * Filter projects based on GitLab project namespace name or id. diff --git a/src/MBO/RemoteGit/Filter/IgnoreRegexpFilter.php b/src/MBO/RemoteGit/Filter/IgnoreRegexpFilter.php index bc9226e..2770275 100644 --- a/src/MBO/RemoteGit/Filter/IgnoreRegexpFilter.php +++ b/src/MBO/RemoteGit/Filter/IgnoreRegexpFilter.php @@ -3,6 +3,7 @@ namespace MBO\RemoteGit\Filter; use MBO\RemoteGit\ProjectInterface; +use MBO\RemoteGit\ProjectFilterInterface; /** * Ignore project according to a regular expression diff --git a/src/MBO/RemoteGit/Filter/IncludeIfHasFileFilter.php b/src/MBO/RemoteGit/Filter/IncludeIfHasFileFilter.php index 86880b9..c97b507 100644 --- a/src/MBO/RemoteGit/Filter/IncludeIfHasFileFilter.php +++ b/src/MBO/RemoteGit/Filter/IncludeIfHasFileFilter.php @@ -2,14 +2,15 @@ namespace MBO\RemoteGit\Filter; +use Psr\Log\LoggerInterface; + use MBO\RemoteGit\ProjectInterface; +use MBO\RemoteGit\ProjectFilterInterface; use MBO\RemoteGit\ClientInterface as GitClientInterface; -use Psr\Log\LoggerInterface; + /** * Accept projects if git contains a given file - * - * TODO remove (done at git listing level) */ class IncludeIfHasFileFilter implements ProjectFilterInterface { diff --git a/src/MBO/RemoteGit/Filter/ProjectTypeFilter.php b/src/MBO/RemoteGit/Filter/ProjectTypeFilter.php index 7a4e79b..08cfbe1 100644 --- a/src/MBO/RemoteGit/Filter/ProjectTypeFilter.php +++ b/src/MBO/RemoteGit/Filter/ProjectTypeFilter.php @@ -2,9 +2,12 @@ namespace MBO\RemoteGit\Filter; +use Psr\Log\LoggerInterface; + use MBO\RemoteGit\ProjectInterface; +use MBO\RemoteGit\ProjectFilterInterface; use MBO\RemoteGit\ClientInterface as GitClientInterface; -use Psr\Log\LoggerInterface; + /** * Ignore project according to their type diff --git a/src/MBO/RemoteGit/FindOptions.php b/src/MBO/RemoteGit/FindOptions.php index e02f180..1996f09 100644 --- a/src/MBO/RemoteGit/FindOptions.php +++ b/src/MBO/RemoteGit/FindOptions.php @@ -32,14 +32,15 @@ class FindOptions { private $users = array(); /** - * Filters not appliable throw API usage + * Additional filter that can't be implemented throw + * project listing API parameters * - * @var FilterCollection + * @var ProjectFilterInterface */ - private $filterCollection ; + private $filter ; public function __construct(){ - $this->filterCollection = new FilterCollection(); + $this->filter = new FilterCollection(); } /** @@ -78,75 +79,75 @@ public function setSearch(string $search) /** - * Get filters not appliable throw API usage + * Get filter according to organizations * - * @return FilterCollection + * @return string[] */ - public function getFilterCollection() + public function getOrganizations() { - return $this->filterCollection; + return $this->organizations; } /** - * Set filters not appliable throw API usage + * Set filter according to organizations * - * @param FilterCollection $filterCollection Filters not appliable throw API usage + * @param string[] $organizations Filter according to organizations * * @return self */ - public function setFilterCollection(FilterCollection $filterCollection) + public function setOrganizations(array $organizations) { - $this->filterCollection = $filterCollection; + $this->organizations = $organizations; return $this; } /** - * Get filter according to organizations + * Get filter according to user names * * @return string[] */ - public function getOrganizations() + public function getUsers() { - return $this->organizations; + return $this->users; } /** - * Set filter according to organizations + * Set filter according to user names * - * @param string[] $organizations Filter according to organizations + * @param string[] $users Filter according to user names * * @return self */ - public function setOrganizations(array $organizations) + public function setUsers(array $users) { - $this->organizations = $organizations; + $this->users = $users; return $this; } /** - * Get filter according to user names + * Get project listing API parameters * - * @return string[] + * @return ProjectFilterInterface */ - public function getUsers() + public function getFilter() { - return $this->users; + return $this->filter; } /** - * Set filter according to user names + * Set project listing API parameters * - * @param string[] $users Filter according to user names + * @param ProjectFilterInterface $filter project listing API parameters * * @return self */ - public function setUsers(array $users) + public function setFilter(ProjectFilterInterface $filter) { - $this->users = $users; + $this->filter = $filter; return $this; } diff --git a/src/MBO/RemoteGit/GithubClient.php b/src/MBO/RemoteGit/Github/GithubClient.php similarity index 93% rename from src/MBO/RemoteGit/GithubClient.php rename to src/MBO/RemoteGit/Github/GithubClient.php index 164bac3..0949c95 100644 --- a/src/MBO/RemoteGit/GithubClient.php +++ b/src/MBO/RemoteGit/Github/GithubClient.php @@ -1,11 +1,15 @@ getUsers() as $user ){ $result = array_merge($result,$this->findByUser( $user, - $options->getFilterCollection() + $options->getFilter() )); } foreach ( $options->getOrganizations() as $org ){ $result = array_merge($result,$this->findByOrg( $org, - $options->getFilterCollection() + $options->getFilter() )); } return $result; diff --git a/src/MBO/RemoteGit/GithubProject.php b/src/MBO/RemoteGit/Github/GithubProject.php similarity index 92% rename from src/MBO/RemoteGit/GithubProject.php rename to src/MBO/RemoteGit/Github/GithubProject.php index 2fac194..7bcbf6d 100644 --- a/src/MBO/RemoteGit/GithubProject.php +++ b/src/MBO/RemoteGit/Github/GithubProject.php @@ -1,6 +1,8 @@ getUsers() as $user ){ $result = array_merge($result,$this->findByUser( $user, - $options->getFilterCollection() + $options->getFilter() )); } foreach ( $options->getOrganizations() as $org ){ $result = array_merge($result,$this->findByGroup( $org, - $options->getFilterCollection() + $options->getFilter() )); } return $result; @@ -113,7 +117,7 @@ protected function findBySearch(FindOptions $options){ return $this->fetchAllPages( $path, $params, - $options->getFilterCollection() + $options->getFilter() ); } diff --git a/src/MBO/RemoteGit/GitlabProject.php b/src/MBO/RemoteGit/Gitlab/GitlabProject.php similarity index 93% rename from src/MBO/RemoteGit/GitlabProject.php rename to src/MBO/RemoteGit/Gitlab/GitlabProject.php index 783cc78..8af5634 100644 --- a/src/MBO/RemoteGit/GitlabProject.php +++ b/src/MBO/RemoteGit/Gitlab/GitlabProject.php @@ -1,6 +1,8 @@ addArgument('gitlab-token') /* - * Project listing options (git level) + * Project listing options (hosted git api level) */ ->addOption('orgs', 'o', InputOption::VALUE_REQUIRED, 'Find projects according to given organization names') ->addOption('users', 'u', InputOption::VALUE_REQUIRED, 'Find projects according to given user names') - ->addOption('projectFilter', 'p', InputOption::VALUE_OPTIONAL, 'filter for projects (deprecated : see organization and users)', null) /* @@ -134,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { * Create project filters according to input arguments */ $filterCollection = new FilterCollection($logger); - $findOptions->setFilterCollection($filterCollection); + $findOptions->setFilter($filterCollection); /* ignore if 'composer.json' is not available */ $filterCollection->addFilter(new IncludeIfHasFileFilter( diff --git a/tests/RemoteGit/Filter/FilterCollectionTest.php b/tests/RemoteGit/Filter/FilterCollectionTest.php index a78d753..4987838 100644 --- a/tests/RemoteGit/Filter/FilterCollectionTest.php +++ b/tests/RemoteGit/Filter/FilterCollectionTest.php @@ -6,9 +6,9 @@ use Psr\Log\NullLogger; -use MBO\RemoteGit\Filter\FilterCollection; use MBO\RemoteGit\ProjectInterface; -use MBO\RemoteGit\Filter\ProjectFilterInterface; +use MBO\RemoteGit\ProjectFilterInterface; +use MBO\RemoteGit\Filter\FilterCollection; /** * Test FilterCollection diff --git a/tests/RemoteGit/Filter/IgnoreRegexpFilterTest.php b/tests/RemoteGit/Filter/IgnoreRegexpFilterTest.php index fa25c62..87d1b16 100644 --- a/tests/RemoteGit/Filter/IgnoreRegexpFilterTest.php +++ b/tests/RemoteGit/Filter/IgnoreRegexpFilterTest.php @@ -6,8 +6,9 @@ use Symfony\Component\Console\Tester\CommandTester; -use MBO\RemoteGit\Filter\IgnoreRegexpFilter; use MBO\RemoteGit\ProjectInterface; +use MBO\RemoteGit\Filter\IgnoreRegexpFilter; + /** * Test IgnoreRegexpFilter diff --git a/tests/RemoteGit/GithubClientTest.php b/tests/RemoteGit/GithubClientTest.php index ae3c614..fb4b8f4 100644 --- a/tests/RemoteGit/GithubClientTest.php +++ b/tests/RemoteGit/GithubClientTest.php @@ -10,10 +10,12 @@ use Psr\Log\NullLogger; use MBO\RemoteGit\ClientOptions; use MBO\RemoteGit\ClientFactory; -use MBO\RemoteGit\GithubClient; -use MBO\RemoteGit\GithubProject; use MBO\RemoteGit\FindOptions; +use MBO\RemoteGit\Github\GithubClient; +use MBO\RemoteGit\Github\GithubProject; + + class GithubClientTest extends TestCase { /** diff --git a/tests/RemoteGit/GitlabClientTest.php b/tests/RemoteGit/GitlabClientTest.php index 23e6786..adc4102 100644 --- a/tests/RemoteGit/GitlabClientTest.php +++ b/tests/RemoteGit/GitlabClientTest.php @@ -5,13 +5,14 @@ use MBO\SatisGitlab\Tests\TestCase; use GuzzleHttp\Client as GuzzleHttpClient; -use MBO\RemoteGit\GitlabClient; use Psr\Log\NullLogger; use MBO\RemoteGit\ClientOptions; use MBO\RemoteGit\ClientFactory; use MBO\RemoteGit\FindOptions; +use MBO\RemoteGit\Gitlab\GitlabClient; +use MBO\RemoteGit\Gitlab\GitlabProject; class GitlabClientTest extends TestCase {