Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Auth;
4
 
5
class Recaller
6
{
7
    /**
8
     * The "recaller" / "remember me" cookie string.
9
     *
10
     * @var string
11
     */
12
    protected $recaller;
13
 
14
    /**
15
     * Create a new recaller instance.
16
     *
17
     * @param  string  $recaller
18
     * @return void
19
     */
20
    public function __construct($recaller)
21
    {
22
        $this->recaller = @unserialize($recaller, ['allowed_classes' => false]) ?: $recaller;
23
    }
24
 
25
    /**
26
     * Get the user ID from the recaller.
27
     *
28
     * @return string
29
     */
30
    public function id()
31
    {
32
        return explode('|', $this->recaller, 3)[0];
33
    }
34
 
35
    /**
36
     * Get the "remember token" token from the recaller.
37
     *
38
     * @return string
39
     */
40
    public function token()
41
    {
42
        return explode('|', $this->recaller, 3)[1];
43
    }
44
 
45
    /**
46
     * Get the password from the recaller.
47
     *
48
     * @return string
49
     */
50
    public function hash()
51
    {
52
        return explode('|', $this->recaller, 4)[2];
53
    }
54
 
55
    /**
56
     * Determine if the recaller is valid.
57
     *
58
     * @return bool
59
     */
60
    public function valid()
61
    {
62
        return $this->properString() && $this->hasAllSegments();
63
    }
64
 
65
    /**
66
     * Determine if the recaller is an invalid string.
67
     *
68
     * @return bool
69
     */
70
    protected function properString()
71
    {
72
        return is_string($this->recaller) && str_contains($this->recaller, '|');
73
    }
74
 
75
    /**
76
     * Determine if the recaller has all segments.
77
     *
78
     * @return bool
79
     */
80
    protected function hasAllSegments()
81
    {
82
        $segments = explode('|', $this->recaller);
83
 
84
        return count($segments) >= 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
85
    }
86
 
87
    /**
88
     * Get the recaller's segments.
89
     *
90
     * @return array
91
     */
92
    public function segments()
93
    {
94
        return explode('|', $this->recaller);
95
    }
96
}