| @@ 39-49 (lines=11) @@ | ||
| 36 | return "https://www.gravatar.com/avatar/" . md5(strtolower(trim($email))); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function getAll() |
|
| 40 | { |
|
| 41 | $comments = $this->findAll(); |
|
| 42 | ||
| 43 | return array_map(function ($comment) { |
|
| 44 | $user = $this->user($comment->user_id); |
|
| 45 | $comment->gravatar = $this->gravatar($user->email); |
|
| 46 | $comment->username = $user->username; |
|
| 47 | return $comment; |
|
| 48 | }, $comments); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function get($id) |
|
| 52 | { |
|
| @@ 51-58 (lines=8) @@ | ||
| 48 | }, $comments); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function get($id) |
|
| 52 | { |
|
| 53 | $comment = $this->find("id", $id); |
|
| 54 | $user = $this->user($comment->user_id); |
|
| 55 | $comment->gravatar = $this->gravatar($user->email); |
|
| 56 | $comment->username = $user->username; |
|
| 57 | return $comment; |
|
| 58 | } |
|
| 59 | ||
| 60 | public function user($id) |
|
| 61 | { |
|