Issues (43)

src/SendsMagicLinkEmails.php (7 issues)

1
<?php
2
3
namespace Soved\Laravel\Magic\Auth;
4
5
use Illuminate\Http\Request;
0 ignored issues
show
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\Facades\Auth;
7
use Soved\Laravel\Magic\Auth\Links\LinkBroker;
8
9
trait SendsMagicLinkEmails
10
{
11
    /**
12
     * Send a magic link to the given user.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
0 ignored issues
show
The type Illuminate\Http\JsonResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
The type Illuminate\Http\RedirectResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
     */
17
    public function sendMagicLinkEmail(Request $request)
18
    {
19
        $this->validateEmail($request);
20
21
        $response = $this->broker()->sendMagicLink(
22
            $request->only('email')
23
        );
24
25
        return $response == LinkBroker::MAGIC_LINK_SENT
26
            ? $this->sendMagicLinkResponse($response)
27
            : $this->sendMagicLinkFailedResponse($request);
28
    }
29
30
    /**
31
     * Validate the email for the given request.
32
     *
33
     * @param  \Illuminate\Http\Request  $request
34
     * @return void
35
     */
36
    protected function validateEmail(Request $request)
37
    {
38
        $this->validate($request, ['email' => 'required|email']);
0 ignored issues
show
The method validate() does not exist on Soved\Laravel\Magic\Auth\SendsMagicLinkEmails. Did you maybe mean validateEmail()? ( Ignorable by Annotation )

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

38
        $this->/** @scrutinizer ignore-call */ 
39
               validate($request, ['email' => 'required|email']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
    }
40
41
    /**
42
     * Get the response for a successfully sent magic link.
43
     *
44
     * @param  string  $response
45
     * @return \Illuminate\Http\RedirectResponse
46
     */
47
    protected function sendMagicLinkResponse(string $response)
48
    {
49
        return back()->with('status', __($response));
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

49
        return back()->with('status', /** @scrutinizer ignore-call */ __($response));
Loading history...
The function back was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

49
        return /** @scrutinizer ignore-call */ back()->with('status', __($response));
Loading history...
50
    }
51
52
    /**
53
     * Get the response for a failed magic link.
54
     *
55
     * @param  \Illuminate\Http\Request  $request
56
     * @return \Illuminate\Http\RedirectResponse
57
     */
58
    protected function sendMagicLinkFailedResponse(Request $request)
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

58
    protected function sendMagicLinkFailedResponse(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
        // We will send the success response to prevent user enumeration
61
        return $this->sendMagicLinkResponse(LinkBroker::MAGIC_LINK_SENT);
62
    }
63
64
    /**
65
     * Get the broker to be used during magic authentication.
66
     *
67
     * @return \Soved\Laravel\Magic\Auth\Links\LinkBroker
68
     */
69
    public function broker()
70
    {
71
        $userProvider = Auth::getProvider();
72
73
        return new LinkBroker($userProvider);
74
    }
75
}
76