StackOverflowJob   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 42
c 1
b 0
f 0
dl 0
loc 123
rs 10
wmc 20

16 Methods

Rating   Name   Duplication   Size   Complexity  
A setJobId() 0 3 1
A getRefinedUrl() 0 14 3
A setResultId() 0 3 1
A getResultId() 0 3 1
A setLogo() 0 3 1
A setLocation() 0 3 1
A setTitle() 0 3 1
A allAttributesDefined() 0 19 3
A getTitle() 0 3 1
A getPreviewUrl() 0 3 1
A getJobId() 0 3 1
A setPreviewUrl() 0 3 1
A getCompany() 0 3 1
A getLogo() 0 3 1
A setCompany() 0 3 1
A getLocation() 0 3 1
1
<?php
2
3
namespace Coco\SourceWatcher\Vendors\StackOverflow;
4
5
/**
6
 * Class StackOverflowJob
7
 *
8
 * @package Coco\SourceWatcher\Vendors\StackOverflow
9
 */
10
class StackOverflowJob
11
{
12
    private string $baseURL = "https://stackoverflow.com";
13
14
    private ?string $jobId = null;
15
16
    private ?string $resultId = null;
17
18
    private ?string $previewUrl = null;
19
20
    private ?string $logo = "https://pbs.twimg.com/profile_images/425274582581264384/X3QXBN8C.jpeg";
21
22
    private ?string $title = null;
23
24
    private ?string $company = null;
25
26
    private ?string $location = null;
27
28
    public function getJobId () : ?string
29
    {
30
        return $this->jobId;
31
    }
32
33
    public function setJobId ( ?string $jobId ) : void
34
    {
35
        $this->jobId = $jobId;
36
    }
37
38
    public function getResultId () : ?string
39
    {
40
        return $this->resultId;
41
    }
42
43
    public function setResultId ( ?string $resultId ) : void
44
    {
45
        $this->resultId = $resultId;
46
    }
47
48
    public function getPreviewUrl () : ?string
49
    {
50
        return $this->previewUrl;
51
    }
52
53
    public function setPreviewUrl ( ?string $previewUrl ) : void
54
    {
55
        $this->previewUrl = $previewUrl;
56
    }
57
58
    public function getLogo () : ?string
59
    {
60
        return $this->logo;
61
    }
62
63
    public function setLogo ( ?string $logo ) : void
64
    {
65
        $this->logo = $logo;
66
    }
67
68
    public function getTitle () : ?string
69
    {
70
        return $this->title;
71
    }
72
73
    public function setTitle ( ?string $title ) : void
74
    {
75
        $this->title = $title;
76
    }
77
78
    public function getCompany () : ?string
79
    {
80
        return $this->company;
81
    }
82
83
    public function setCompany ( ?string $company ) : void
84
    {
85
        $this->company = $company;
86
    }
87
88
    public function getLocation () : ?string
89
    {
90
        return $this->location;
91
    }
92
93
    public function setLocation ( ?string $location ) : void
94
    {
95
        $this->location = $location;
96
    }
97
98
    public function getRefinedUrl () : string
99
    {
100
        $currentPreviewUrl = substr( $this->previewUrl, 0,
0 ignored issues
show
Bug introduced by
It seems like $this->previewUrl can also be of type null; however, parameter $string of substr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

100
        $currentPreviewUrl = substr( /** @scrutinizer ignore-type */ $this->previewUrl, 0,
Loading history...
101
            strlen( $this->baseURL ) ) === $this->baseURL ? $this->previewUrl : $this->baseURL . $this->previewUrl;
102
103
        $pieces = explode( "?", $currentPreviewUrl );
0 ignored issues
show
Bug introduced by
It seems like $currentPreviewUrl can also be of type null; however, parameter $string of explode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

103
        $pieces = explode( "?", /** @scrutinizer ignore-type */ $currentPreviewUrl );
Loading history...
104
105
        $refinedUrl = "";
106
107
        if ( !empty( $pieces ) ) {
108
            $refinedUrl = $pieces[0];
109
        }
110
111
        return $refinedUrl;
112
    }
113
114
    public function allAttributesDefined () : bool
115
    {
116
        $variablesToValidate = [
117
            $this->jobId,
118
            $this->resultId,
119
            $this->previewUrl,
120
            $this->logo,
121
            $this->title,
122
            $this->company,
123
            $this->location
124
        ];
125
126
        foreach ( $variablesToValidate as $currentVariable ) {
127
            if ( empty( $currentVariable ) ) {
128
                return false;
129
            }
130
        }
131
132
        return true;
133
    }
134
}
135