GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ApiController::file_put()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 4
nc 3
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Azizbek Eshonaliyev
5
 * Date: 2/15/2019
6
 * Time: 5:01 PM
7
 */
8
9
namespace Goodoneuz\PayUz\Http\Controllers;
10
11
12
use Illuminate\Http\Request;
13
use App\Http\Controllers\Controller;
14
15
class ApiController extends Controller
16
{
17
    const ERROR_RESPONSE = 'error';
18
    const SUCCESS_RESPONSE = 'success';
19
20
    public function file_put(Request $request)
21
    {
22
        if(isset($request['content']) && isset($request['file_name']))
23
        {
24
            if (file_exists(base_path('/app/Http/Controllers/Payments/'.$request['file_name'].'.php'))){
25
                file_put_contents(base_path('/app/Http/Controllers/Payments/'.$request['file_name'].'.php'), $request['content']);
26
            }else{
27
                return response()->json([
0 ignored issues
show
Bug introduced by
The method json does only exist in Illuminate\Contracts\Routing\ResponseFactory, but not in Illuminate\Http\Response.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
28
                    'responseStatus'    => self::ERROR_RESPONSE,
29
                    'message'           => trans('pay-uz::strings.file_not_found')
30
                ]);           
31
            }
32
        }
33
        else
34
        {
35
            return response()->json([
36
                'responseStatus'    => self::ERROR_RESPONSE,
37
                'message'           => trans('pay-uz::strings.request_validate_error')
38
            ]);       
39
        }
40
        return response()->json([
41
            'responseStatus'    => self::SUCCESS_RESPONSE,
42
            'message'           => trans('pay-uz::strings.store_success')
43
        ]);       
44
    }
45
}
46