Passed
Push — master ( 270226...e22eb7 )
by James
06:04 queued 11s
created

HaveAccess::haveAccess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
1
<?php
2
/**
3
 * HaveAccess.php
4
 * Copyright (c) 2019 - 2020 [email protected]
5
 *
6
 * This file is part of the Firefly III CSV importer
7
 * (https://github.com/firefly-iii-csv-importer).
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
21
 */
22
23
namespace App\Console;
24
25
26
use App\Exceptions\ApiHttpException;
27
use App\Services\FireflyIIIApi\Request\SystemInformationRequest;
28
29
/**
30
 * Trait HaveAccess
31
 */
32
trait HaveAccess
33
{
34
    /**
35
     * @return bool
36
     */
37
    private function haveAccess(): bool
38
    {
39
        $request = new SystemInformationRequest();
40
        try {
41
            $request->get();
42
        } catch (ApiHttpException $e) {
43
            $this->error(sprintf('Could not connect to Firefly III: %s', $e->getMessage()));
0 ignored issues
show
Bug introduced by
It seems like error() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
            $this->/** @scrutinizer ignore-call */ 
44
                   error(sprintf('Could not connect to Firefly III: %s', $e->getMessage()));
Loading history...
44
45
            return false;
46
        }
47
48
        return true;
49
    }
50
}