Create::addAttachment()   A
last analyzed

Complexity

Conditions 2
Paths 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 4
nop 0
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
namespace Integrations\Connectors\SenhorVerdugo;
4
5
6
class Create extends SenhorVerdugo
7
{
8 View Code Duplication
    public function issueWatcher()
0 ignored issues
show
Duplication introduced by
This method 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...
9
    {
10
        $issueKey = 'TEST-961';
11
12
        try {
13
            $issueService = new IssueService();
14
            
15
            // watcher's id
16
            $watcher = 'lesstif';
17
            
18
            $issueService->addWatcher($issueKey, $watcher);
19
            
20
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
21
            $this->assertTrue(false, 'add watcher Failed : '.$e->getMessage());
22
        }
23
    }
24
25 View Code Duplication
    public function issueWorklog()
0 ignored issues
show
Duplication introduced by
This method 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...
26
    {
27
        $issueKey = 'TEST-961';
28
29
        try {
30
            $workLog = new Worklog();
31
        
32
            $workLog->setComment('I did some work here.')
33
                ->setStarted("2016-05-28 12:35:54")
34
                ->setTimeSpent('1d 2h 3m');
35
        
36
            $issueService = new IssueService();
37
        
38
            $ret = $issueService->addWorklog($issueKey, $workLog);
39
        
40
            $workLogid = $ret->{'id'};
0 ignored issues
show
Unused Code introduced by
$workLogid is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
41
        
42
            var_dump($ret);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($ret); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
43
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
44
            $this->assertTrue(false, 'Create Failed : '.$e->getMessage());
45
        }
46
        
47
    }
48
49
50
    public function issueLink()
51
    {
52
        try {
53
            $il = new IssueLink();
54
55
            $il->setInwardIssue('TEST-258')
56
                ->setOutwardIssue('TEST-249')
57
                ->setLinkTypeName('Relates')
58
                ->setComment('Linked related issue via REST API.');
59
                    
60
            $ils = new IssueLinkService();
61
62
            $ret = $ils->addIssueLink($il);
0 ignored issues
show
Unused Code introduced by
$ret is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
63
64
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
65
            print("Error Occured! " . $e->getMessage());
66
        }
67
    }
68
69
70 View Code Duplication
    public function issueRemoteLink()
0 ignored issues
show
Duplication introduced by
This method 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...
71
    {
72
        $issueKey = 'TEST-316';
73
74
        try {
75
            $issueService = new IssueService();
76
77
            $ril = new RemoteIssueLink();
78
79
            $ril->setUrl('http://www.mycompany.com/support?id=1')
80
                ->setTitle('Remote Link Title')
81
                ->setRelationship('causes')
82
                ->setSummary('Crazy customer support issue');
83
84
            $rils = $issueService->createOrUpdateRemoteIssueLink($issueKey, $ril);
85
86
            // rils is array of RemoteIssueLink classes
87
            var_dump($rils);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($rils); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
88
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
89
            $this->assertTrue(false, 'Create Failed : '.$e->getMessage());
90
        }
91
    }
92
93
    public function comment()
94
    {
95
        $issueKey = "TEST-879";
96
97
        try {            
98
            $comment = new Comment();
99
100
            $body = "<<<COMMENT
101
            Adds a new comment to an issue.
102
            * Bullet 1
103
            * Bullet 2
104
            ** sub Bullet 1
105
            ** sub Bullet 2
106
            * Bullet 3
107
            COMMENT;";
108
109
            $comment->setBody($body)
110
                ->setVisibility('role', 'Users');
111
            ;
112
113
            $issueService = new IssueService();
114
            $ret = $issueService->addComment($issueKey, $comment);
115
            print_r($ret);
116
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
117
            $this->assertTrue(false, "add Comment Failed : " . $e->getMessage());
118
        }
119
    }
120
121
    public function addAttachment()
122
    {
123
        $issueKey = "TEST-879";
124
125
        try {
126
            $issueService = new IssueService();
127
        
128
            // multiple file upload support.
129
            $ret = $issueService->addAttachments(
130
                $issueKey, 
131
                ['screen_capture.png', 'bug-description.pdf', 'README.md']
132
            );
133
        
134
            print_r($ret);
135
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
136
            $this->assertTrue(false, "Attach Failed : " . $e->getMessage());
137
        }
138
        
139
    }
140
141
    public function multipleIssue()
142
    {
143
144
        try {
145
            $issueFieldOne = new IssueField();
146
147
            $issueFieldOne->setProjectKey("TEST")
148
                ->setSummary("something's wrong")
149
                ->setPriorityName("Critical")
150
                ->setIssueType("Bug")
151
                ->setDescription("Full description for issue");
152
153
            $issueFieldTwo = new IssueField();
154
155
            $issueFieldTwo->setProjectKey("TEST")
156
                ->setSummary("something else is wrong")
157
                ->setPriorityName("Critical")
158
                ->setIssueType("Bug")
159
                ->setDescription("Full description for second issue");
160
            
161
            $issueService = new IssueService();
162
163
            $ret = $issueService->createMultiple([$issueFieldOne, $issueFieldTwo]);
164
            
165
            //If success, returns an array of the created issues
166
            var_dump($ret);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($ret); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
167
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
168
            print("Error Occured! " . $e->getMessage());
169
        }
170
    }
171
172
    public function issue()
173
    {
174
        try {
175
            $issueField = new IssueField();
176
        
177
            $issueField->setProjectKey("TEST")
178
                ->setSummary("something's wrong")
179
                ->setAssigneeName("lesstif")
180
                ->setPriorityName("Critical")
181
                ->setIssueType("Bug")
182
                ->setDescription("Full description for issue")
183
                ->addVersion(["1.0.1", "1.0.3"])
184
                ->addComponents(['Component-1', 'Component-2'])
185
                        // set issue security if you need.
186
                ->setSecurityId(10001 /* security scheme id */)
187
                ->setDueDate('2019-06-19');
188
            
189
            $issueService = new IssueService();
190
        
191
            $ret = $issueService->create($issueField);
192
            
193
            //If success, Returns a link to the created issue.
194
            var_dump($ret);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($ret); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
195
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
196
            print("Error Occured! " . $e->getMessage());
197
        }
198
    }
199
200
    public function field()
201
    {
202
203
        try {
204
            $field = new Field();
205
            
206
            $field->setName("New custom field")
207
                ->setDescription("Custom field for picking groups")
208
                ->setType("com.atlassian.SenhorVerdugo.plugin.system.customfieldtypes:grouppicker")
209
                ->setSearcherKey("com.atlassian.SenhorVerdugo.plugin.system.customfieldtypes:grouppickersearcher");
210
211
            $fieldService = new FieldService();
212
213
            $ret = $fieldService->create($field);
214
            
215
            var_dump($ret);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($ret); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
216
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
217
            $this->assertTrue(false, 'Field Create Failed : '.$e->getMessage());
218
        }
219
    }
220
221
    public function project(ProjectModel $project)
222
    {
223
        
224
        try {
225
            $p = new Project();
226
        
227
            $p->setKey('EX')
228
                ->setName('Example')
229
                ->setProjectTypeKey('organizer')
230
                ->setProjectTemplateKey('com.atlassian.SenhorVerdugo-core-project-templates:SenhorVerdugo-core-project-management')
231
                ->setDescription('Example Project description')
232
                ->setLead('lesstif')
233
                ->setUrl('http://example.com')
234
                ->setAssigneeType('PROJECT_LEAD')
235
                ->setAvatarId(10130)
236
                ->setIssueSecurityScheme(10000)
237
                ->setPermissionScheme(10100)
238
                ->setNotificationScheme(10100)
239
                ->setCategoryId(10100);
240
        
241
            $proj = new ProjectService();
242
        
243
            $pj = $proj->createProject($p);
244
           
245
            // "http://example.com/rest/api/2/project/10042"
246
            var_dump($pj->self);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($pj->self); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
247
            // 10042 
248
            var_dump($pj->id);
249
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
250
            print("Error Occured! " . $e->getMessage());
251
        }
252
    }
253
254
    public function user()
255
    {
256
        try {
257
            $us = new UserService();
258
        
259
            // create new user
260
            $user = $us->create(
261
                [
262
                    'name'=>'charlie',
263
                    'password' => 'abracadabra',
264
                    'emailAddress' => '[email protected]',
265
                    'displayName' => 'Charlie of Atlassian',
266
                ]
267
            );
268
        
269
            var_dump($user);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($user); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
270
        } catch (SenhorVerdugoException $e) {
0 ignored issues
show
Bug introduced by
The class Integrations\Connectors\...\SenhorVerdugoException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
271
            print("Error Occured! " . $e->getMessage());
272
        }
273
    }
274
}
275