1 <?php
2 3 4 5 6 7
8 namespace Skimia\ApiFusion\Domain\Users;
9
10 use Skimia\ApiFusion\Domain\Contracts\ServiceUserContract;
11 use Cartalyst\Sentinel\Users\EloquentUser;
12
13 class SentinelServiceUserAdapter implements ServiceUserContract
14 {
15 protected $user = null;
16
17 protected $id = null;
18
19 public function __construct(EloquentUser $user = null)
20 {
21 if ($user) {
22 $this->user = $user;
23 $this->id = $this->user->id;
24 }
25 }
26
27 public function id()
28 {
29 return $this->id;
30 }
31
32 public function isAuthenticated()
33 {
34 return ! empty($this->user);
35 }
36
37 public function hasRole($role)
38 {
39 if ($this->user) {
40 return $this->user->hasRole($role);
41 }
42
43 return false;
44 }
45 }
46