| Total Complexity | 7 | 
| Total Lines | 67 | 
| Duplicated Lines | 0 % | 
| Changes | 3 | ||
| Bugs | 1 | Features | 0 | 
| 1 | <?php  | 
            ||
| 7 | trait RememberDeviceTrait  | 
            ||
| 8 | { | 
            ||
| 9 | /**  | 
            ||
| 10 | * The column name of the "remember device" token.  | 
            ||
| 11 | *  | 
            ||
| 12 | * @var string  | 
            ||
| 13 | */  | 
            ||
| 14 | protected $rememberDeviceTokenName = 'remember_device_token';  | 
            ||
| 15 | |||
| 16 | /**  | 
            ||
| 17 | * Get the token value for the "remember device" session.  | 
            ||
| 18 | *  | 
            ||
| 19 | * @return string|null  | 
            ||
| 20 | */  | 
            ||
| 21 | public function getRememberDeviceToken()  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 22 |     { | 
            ||
| 23 |         if (!empty($this->getRememberDeviceTokenName())) { | 
            ||
| 24 |             return (string)$this->{$this->getRememberDeviceTokenName()}; | 
            ||
| 25 | }  | 
            ||
| 26 | }  | 
            ||
| 27 | |||
| 28 | /**  | 
            ||
| 29 | * Set the token value for the "remember device" session.  | 
            ||
| 30 | *  | 
            ||
| 31 | * @param string $value  | 
            ||
| 
                                                                                                    
                         1 ignored issue 
                            –
                            show
                         | 
                |||
| 32 | * @return void  | 
            ||
| 33 | */  | 
            ||
| 34 | public function setRememberDeviceToken($value)  | 
            ||
| 
                                                                                                                                                                                                            
                         1 ignored issue 
                            –
                            show
                         | 
                |||
| 35 |     { | 
            ||
| 36 |         if (!empty($this->getRememberDeviceTokenName())) { | 
            ||
| 37 |             $this->{$this->getRememberDeviceTokenName()} = $value; | 
            ||
| 38 | }  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 | /**  | 
            ||
| 42 | * Get the column name for the "remember device" token.  | 
            ||
| 43 | *  | 
            ||
| 44 | * @return string  | 
            ||
| 45 | */  | 
            ||
| 46 | public function getRememberDeviceTokenName()  | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 | /**  | 
            ||
| 52 | * Refresh the "remember device" token for the User.  | 
            ||
| 53 | *  | 
            ||
| 54 | * @return void  | 
            ||
| 55 | */  | 
            ||
| 56 | public function cycleRememberDeviceToken()  | 
            ||
| 57 |     { | 
            ||
| 58 | $this->setRememberDeviceToken(Str::random(60));  | 
            ||
| 59 | $timestamps = $this->timestamps;  | 
            ||
| 60 | $this->timestamps = false;  | 
            ||
| 61 | $this->save();  | 
            ||
| 62 | $this->timestamps = $timestamps;  | 
            ||
| 63 | }  | 
            ||
| 64 | |||
| 65 | /**  | 
            ||
| 66 | * Get a key to be used by a cookie for the  | 
            ||
| 67 | * remember device token.  | 
            ||
| 68 | *  | 
            ||
| 69 | * @return string  | 
            ||
| 
                                                                                                    
                         1 ignored issue 
                            –
                            show
                         | 
                |||
| 70 | */  | 
            ||
| 71 | public function getRememberDeviceKey(): string  | 
            ||
| 74 | }  | 
            ||
| 75 | }  | 
            ||
| 76 |