Connection.php 636 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php

namespace App\Repository;

use GuzzleHttp\Client;

class Connection
{
    private $repo;

    public function __construct(Client $client)
    {
        $url = env('REPOSITORY_URL') ?? env('GITLAB_URL');
        if (parse_url($url, PHP_URL_HOST) == 'github.com') {
            $this->repo = new Github($client, $url);
        } else {
            $this->repo = new Gitlab($client, $url);
        }
    }

    public function mergeRequests($state) {
        return $this->repo->mergeRequests($state);
    }

    public function getNewFiles($merge_request_iid) {
        return $this->repo->getNewFiles($merge_request_iid);
    }
}