ChatController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B index() 0 28 5
A __construct() 0 4 1
1
0 ignored issues
show
Security Bug introduced by
It is not recommended to output anything before PHP's opening tag in non-template files.
Loading history...
2
<?php 
3
4
5
    use LaravelRealtimeChat\Repositories\Conversation\ConversationRepository;
0 ignored issues
show
Bug introduced by
The type LaravelRealtimeChat\Repo...\ConversationRepository 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 LaravelRealtimeChat\Repositories\User\UserRepository;
0 ignored issues
show
Bug introduced by
The type LaravelRealtimeChat\Repo...ies\User\UserRepository 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...
7
class ChatController extends \BaseController {
8
9
    /**
10
     * @var LaravelRealtimeChat\Repositories\ConversationRepository
0 ignored issues
show
Bug introduced by
The type LaravelRealtimeChat\Repo...\ConversationRepository 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...
11
     */
12
    private $conversationRepository; 
13
14
    /**
15
     * @var LaravelRealtimeChat\Repositories\UserRepository
0 ignored issues
show
Bug introduced by
The type LaravelRealtimeChat\Repositories\UserRepository 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
    private $userRepository; 
18
19
    public function __construct(ConversationRepository $conversationRepository, UserRepository $userRepository)
20
    {
21
        $this->conversationRepository = $conversationRepository;
22
        $this->userRepository = $userRepository;
23
    }
24
25
    /**
26
     * Display the chat index.
27
     *
28
     * @return Response
29
     */
30
    public function index() {
31
32
        $viewData = array();
33
34
        if(Input::has('conversation')) {
0 ignored issues
show
Bug introduced by
The type Input 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...
35
            $viewData['current_conversation'] = $this->conversationRepository->getByName(Input::get('conversation'));
36
        } else {
37
            $viewData['current_conversation'] = Auth::user()->conversations()->first();
38
        }
39
40
        if($viewData['current_conversation']) {
41
            Session::set('current_conversation', $viewData['current_conversation']->name);
42
    
43
            foreach($viewData['current_conversation']->messages_notifications as $notification) {
44
                $notification->read = true;
45
                $notification->save();
46
            }
47
        }
48
       
49
        $users = $this->userRepository->getAllExcept(Auth::user()->id);
50
51
        foreach($users as $key => $user) {
52
            $viewData['recipients'][$user->id] = $user->username;
53
        }
54
        
55
        $viewData['conversations'] = Auth::user()->conversations()->get();
56
        
57
        return View::make('templates/chat', $viewData);
58
    }
59
}
60