GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — feature/tweak ( 28e05b )
by jake
02:03
created

MessageAwareTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessenger() 0 8 2
A safeGetMessenger() 0 8 2
1
<?php
2
/**
3
 * Molniya Messenger
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2017 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Middleware
13
 * @package   Jnjxp\Molniya
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2017 Jake Johns
16
 * @license   http://jnj.mit-license.org/2017 MIT License
17
 * @link      http://jakejohns.net
18
 */
19
20
namespace Jnjxp\Molniya;
21
22
use Psr\Http\Message\ServerRequestInterface as Request;
23
24
/**
25
 * MessageHandler
26
 *
27
 * @category Middleware
28
 * @package  Jnjxp\Molniya
29
 * @author   Jake Johns <[email protected]>
30
 * @license  https://jnj.mit-license.org/ MIT License
31
 * @link     https://github.com/
32
 */
33
trait MessageAwareTrait
34
{
35
    /**
36
     * GetMessenger
37
     *
38
     * @param Request $request DESCRIPTION
39
     *
40
     * @return mixed
41
     * @throws \Exception if no mesenger available
42
     *
43
     * @access public
44
     */
45
    public function getMessenger(Request $request)
46
    {
47
        $messenger = $request->getAttribute(MessageHandler::MESSENGER_ATTRIBUTE);
48
        if (! $messenger instanceof Messenger\MessengerInterface) {
49
            throw new \Exception('Invalid Messenger');
50
        }
51
        return $messenger;
52
    }
53
54
    /**
55
     * SafeGetMessenger
56
     *
57
     * @param Request $request DESCRIPTION
58
     *
59
     * @return mixed
60
     *
61
     * @access public
62
     */
63
    public function safeGetMessenger(Request $request)
64
    {
65
        $messenger = $request->getAttribute(MessageHandler::MESSENGER_ATTRIBUTE);
66
        if (! $messenger instanceof Messenger\MessengerInterface) {
67
            $messenger = new Messenger\Messenger;
68
        }
69
        return $messenger;
70
    }
71
}
72