RecordController::sendAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace DoS\SMSBundle\Controller;
4
5
use DoS\ResourceBundle\Controller\ResourceController;
6
use DoS\SMSBundle\Provider\RecordProvider;
7
use DoS\SMSBundle\SMS\StorableSender;
8
use FOS\RestBundle\View\View;
9
use SmsSender\Exception\WrappedException;
10
use Symfony\Component\HttpFoundation\Request;
11
12
class RecordController extends ResourceController
13
{
14
    /**
15
     * @return RecordProvider
16
     */
17
    protected function getRecordProvider()
18
    {
19
        return $this->get('dos.sms.provider.record');
20
    }
21
22
    /**
23
     * @return StorableSender
24
     */
25
    protected function getSmsSender()
26
    {
27
        return $this->get('dos.sms.sender');
28
    }
29
30
    public function sendAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
        return $this->handleView($this->view()->setTemplate($this->config->getTemplate('send.html')));
0 ignored issues
show
Bug introduced by
The property config does not seem to exist. Did you mean requestConfigurationFactory?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The method view() does not seem to exist on object<DoS\SMSBundle\Controller\RecordController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method handleView() does not seem to exist on object<DoS\SMSBundle\Controller\RecordController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
    }
34
35
    public function callbackAction(Request $request, $provider)
36
    {
37
        sleep(5);
38
        $data = array();
39
        $status = 200;
40
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
41
42
        try {
43
            $this->getSmsSender()->acceptCallback($provider, $request->query->all());
44
        } catch (WrappedException $e) {
45
            $data = array('error' => $e->getWrappedException()->getMessage());
46
            $status = 400;
47
        } catch (\Exception $e) {
48
            $data = array('error' => $e->getMessage());
49
            $status = 400;
50
        }
51
52
        return $this->viewHandler->handle($configuration, View::create($data, $status));
53
    }
54
}
55