PixelTracker::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 2
crap 1
1
<?php
2
3
namespace BoxedCode\Tracking\Trackers;
4
5
use BoxedCode\Tracking\Contracts\Tracker as TrackerContract;
6
use BoxedCode\Tracking\TrackableResourceModel;
7
use Illuminate\Http\Request;
8
9
class PixelTracker extends Tracker implements TrackerContract
10
{
11
    /**
12
     * The trackers type handle.
13
     *
14
     * @var string
15
     */
16
    protected $handle = 'pixel';
17
18
    /**
19
     * The trackers route name.
20
     *
21
     * @var string
22
     */
23
    protected $route_name = 'tracking.pixel';
24
25
    /**
26
     * The trackers route parameter.
27
     *
28
     * @var string
29
     */
30
    protected $route_parameter = 'p';
31
32
    /**
33
     * Get the routing path.
34
     *
35
     * @return string
36
     */
37 38
    protected function getRoutingPath()
38
    {
39 38
        $path = parent::getRoutingPath();
40
41 38
        return $path.'.gif';
42
    }
43
44
    /**
45
     * Handle the tracking request.
46
     *
47
     * @param \Illuminate\Http\Request $request
48
     * @param \BoxedCode\Tracking\TrackableResourceModel $model
49
     * @return mixed
50
     */
51 2
    public function handle(Request $request, TrackableResourceModel $model)
52
    {
53 2
        $pixel = base64_decode(
54
            'R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw=='
55 2
        );
56
57 2
        return response($pixel)
58 2
            ->header('Content-Type', 'image/gif')
59 2
            ->header('Cache-Control', 'must-revalidate, no-cache, no-store, private');
60
    }
61
}
62