Completed
Push — master ( ec2395...0dfd17 )
by Sherif
02:09
created

PushNotificationDeviceController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Modules\PushNotificationDevices\Http\Controllers;
4
5
use App\Modules\Core\BaseClasses\BaseApiController;
6
use App\Modules\PushNotificationDevices\Repositories\PushNotificationDeviceRepository;
7
use App\Modules\Core\Utl\CoreConfig;
8
use App\Modules\PushNotificationDevices\Http\Requests\RegisterDevice;
9
use App\Modules\PushNotificationDevices\Http\Requests\InsertPushNotificationDevice;
10
use App\Modules\PushNotificationDevices\Http\Requests\UpdatePushNotificationDevice;
11
12 View Code Duplication
class PushNotificationDeviceController extends BaseApiController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * List of all route actions that the base api controller
16
     * will skip permissions check for them.
17
     * @var array
18
     */
19
    protected $skipPermissionCheck = ['registerDevice'];
20
21
    /**
22
     * Init new object.
23
     *
24
     * @param   PushNotificationDeviceRepository $repo
25
     * @param   CoreConfig                       $config
26
     * @return  void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
27
     */
28
    public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config)
29
    {
30
        parent::__construct($repo, $config, 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice');
31
    }
32
33
    /**
34
     * Insert the given model to storage.
35
     *
36
     * @param InsertPushNotificationDevice $request
37
     * @return \Illuminate\Http\Response
38
     */
39
    public function insert(InsertPushNotificationDevice $request)
40
    {
41
        return new $this->modelResource($this->repo->save($request->all()));
42
    }
43
44
    /**
45
     * Update the given model to storage.
46
     *
47
     * @param UpdatePushNotificationDevice $request
48
     * @return \Illuminate\Http\Response
49
     */
50
    public function update(UpdatePushNotificationDevice $request)
51
    {
52
        return new $this->modelResource($this->repo->save($request->all()));
53
    }
54
55
    /**
56
     * Register the given device to the logged in user.
57
     *
58
     * @param RegisterDevice $request
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function registerDevice(RegisterDevice $request)
62
    {
63
        return new $this->modelResource($this->repo->registerDevice($request->all()));
64
    }
65
}
66