Code Duplication    Length = 49-52 lines in 2 locations

src/Controllers/InstallManagerController.php 1 location

@@ 10-61 (lines=52) @@
7
use Elimuswift\Core\Contacts\RepositoryContract;
8
use Elimuswift\Core\Contacts\CustomersRepository;
9
10
class InstallManagerController extends Controller
11
{
12
    /*
13
    * When including this trait make sure you inject RepositoryContract as $repository
14
    * and CustomersRepository as $customers to the constructor
15
    */
16
    use VerifiesPurchase;
17
18
    /**
19
     * Update Repository.
20
     *
21
     * @var mixed
22
     **/
23
    public $repository;
24
25
    /**
26
     * Customers Repository.
27
     *
28
     * @var mixed
29
     **/
30
    public $customers;
31
32
    /**
33
     * Create a new instance of the UpdatesManagerController::class.
34
     **/
35
    public function __construct(RepositoryContract $repository, CustomersRepository $customers)
36
    {
37
        $this->repository = $repository;
38
        $this->customers = $customers;
39
    }
40
41
    /**
42
     * Get the installer zip file for the version specified
43
     * NOTE: The purchase key must be passed in the request for verification.
44
     *
45
     * @return mixed Illuminate\Http\Response
46
     *
47
     * @param $version Version to fetch
48
     **/
49
    public function getInstaller($version)
50
    {
51
        $response = $this->verifyPurchase();
52
        if (null == $this->customer) {
53
            return $this->invalidKeyResponse();
54
        }
55
        $install = $this->repository->config('install.resourcePath') . "/install_{$version}.zip";
56
        if (file_exists($install)) {
57
            return response()->download($install);
58
        }
59
    }
60
}
61

src/Controllers/UpdateManagerController.php 1 location

@@ 10-58 (lines=49) @@
7
use Elimuswift\Core\Contacts\RepositoryContract;
8
use Elimuswift\Core\Contacts\CustomersRepository;
9
10
class UpdateManagerController extends Controller
11
{
12
    // When including ths trait make sure you inject RepositoryContract as $repository and
13
    // CustomersRepository as $customers to the constructor
14
    use VerifiesPurchase;
15
16
    /**
17
     * Update Repository.
18
     *
19
     * @var mixed
20
     **/
21
    public $repository;
22
23
    /**
24
     * Customers Repository.
25
     *
26
     * @var mixed
27
     **/
28
    public $customers;
29
30
    /**
31
     * Create a new instance of the UpdatesManagerController::class.
32
     **/
33
    public function __construct(RepositoryContract $repository, CustomersRepository $customers)
34
    {
35
        $this->repository = $repository;
36
        $this->customers = $customers;
37
    }
38
39
    /**
40
     * @return mixed Illuminate\Http\Response
41
     *
42
     * @param $version Version to fetch
43
     **/
44
    public function fetchUpdate($version)
45
    {
46
        $this->getCustomer();
47
        if (null == $this->customer) {
48
            return $this->invalidKeyResponse();
49
        }
50
        $update = $this->repository->config('updates.updatesPath') . "/update_{$version}.zip";
51
        if (file_exists($update)) {
52
            return response()->download($update);
53
        }
54
    }
55
}
56