ProjectEnvironment::getPosition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/*
3
 * This file is part of the GitControlBundle package.
4
 *
5
 * (c) Paul Schweppe <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace VersionControl\GitControlBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use VersionControl\DoctrineEncryptBundle\Configuration\Encrypted;
15
use Symfony\Component\Validator\Constraints as Assert;
16
use VersionControl\GitControlBundle\Validator\Constraints as VersionControlAssert;
17
use VersionControl\GitCommandBundle\GitCommands\GitEnvironmentInterface;
18
use Gedmo\Mapping\Annotation as Gedmo;
19
20
/**
21
 * @ORM\Entity
22
 * @ORM\Entity(repositoryClass="VersionControl\GitControlBundle\Repository\ProjectEnvironmentRepository")
23
 * @ORM\Table(name="project_environment")
24
 * @VersionControlAssert\SshDetails()
25
 * @VersionControlAssert\GitFolderExists(groups={"ExistingGit"})
26
 * @VersionControlAssert\GitFolderNotExists(groups={"CloneGit","NewGit"})
27
 */
28
class ProjectEnvironment implements GitEnvironmentInterface
29
{
30
    /**
31
     * @ORM\Id
32
     * @ORM\Column(type="integer")
33
     * @ORM\GeneratedValue(strategy="AUTO")
34
     *
35
     * @var int
36
     */
37
    private $id;
38
39
    /**
40
     * @var string
41
     * @ORM\Column(name="title", type="string", length=80, nullable=true)
42
     * @Assert\NotBlank()
43
     */
44
    private $title;
45
46
    /**
47
     * @var string
48
     * @ORM\Column(name="description", type="string", length=225, nullable=true)
49
     */
50
    private $description;
51
52
    /**
53
     * @var string
54
     * @ORM\Column(name="path", type="string", length=225, nullable=true)
55
     */
56
    private $path;
57
58
    /**
59
     * @var string
60
     * @ORM\Column(name="ssh", type="boolean",nullable=true)
61
     */
62
    private $ssh;
63
64
    /**
65
     * @var string
66
     * @ORM\Column(name="host", type="string", length=225, nullable=true)
67
     */
68
    private $host;
69
70
    /**
71
     * @var string
72
     * @ORM\Column(name="username", type="string", length=225, nullable=true)
73
     */
74
    private $username;
75
76
    /**
77
     * @var string
78
     * @ORM\Column(name="password", type="string", nullable=true)
79
     * @Encrypted
80
     */
81
    private $password;
82
83
    /**
84
     * @var \VersionControl\GitControlBundle\Entity\Project
85
     *
86
     * @Gedmo\SortableGroup
87
     * @ORM\ManyToOne(targetEntity="VersionControl\GitControlBundle\Entity\Project", inversedBy="projectEnvironment")
88
     * @ORM\JoinColumns({
89
     *   @ORM\JoinColumn(name="project_id", referencedColumnName="id")
90
     * })
91
     */
92
    private $project;
93
94
    /**
95
     * @var string
96
     * @ORM\Column(name="private_key", type="string", nullable=true)
97
     * @Encrypted
98
     */
99
    private $privateKey = null;
100
101
    /**
102
     * @var string
103
     * @ORM\Column(name="private_key_password", type="string", nullable=true)
104
     * @Encrypted
105
     */
106
    private $privateKeyPassword = null;
107
108
    /**
109
     * @var \VersionControl\GitControlBundle\Entity\ProjectEnvironmentFilePerm
110
     *
111
     * @ORM\OneToOne(targetEntity="VersionControl\GitControlBundle\Entity\ProjectEnvironmentFilePerm", inversedBy="projectEnvironment", cascade={"persist"})
112
     * @ORM\JoinColumns({
113
     *   @ORM\JoinColumn(name="project_environment_file_perm_id", referencedColumnName="id")
114
     * })
115
     * @Assert\Valid
116
     */
117
    private $projectEnvironmentFilePerm;
118
119
    /**
120
     * @Assert\NotNull(groups={"CloneGit"}))
121
     *
122
     * @var string
123
     */
124
    private $gitCloneLocation;
125
126
    /**
127
     * @Gedmo\SortablePosition
128
     *
129
     * @ORM\Column(name="position", type="integer")
130
     */
131
    private $position;
132
133
    public function __construct()
134
    {
135
    }
136
137
    /**
138
     * Set title.
139
     *
140
     * @param string $title
141
     *
142
     * @return Project
143
     */
144
    public function setTitle($title)
145
    {
146
        $this->title = $title;
147
148
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GitContro...tity\ProjectEnvironment which is incompatible with the documented return type VersionControl\GitControlBundle\Entity\Project.
Loading history...
149
    }
150
151
    /**
152
     * Get title.
153
     *
154
     * @return string
155
     */
156
    public function getTitle()
157
    {
158
        return $this->title;
159
    }
160
161
    /**
162
     * Set description.
163
     *
164
     * @param string $description
165
     *
166
     * @return Project
167
     */
168
    public function setDescription($description)
169
    {
170
        $this->description = $description;
171
172
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GitContro...tity\ProjectEnvironment which is incompatible with the documented return type VersionControl\GitControlBundle\Entity\Project.
Loading history...
173
    }
174
175
    /**
176
     * Get description.
177
     *
178
     * @return string
179
     */
180
    public function getDescription()
181
    {
182
        return $this->description;
183
    }
184
185
    /**
186
     * Set path.
187
     *
188
     * @param string $path
189
     *
190
     * @return Project
191
     */
192
    public function setPath($path)
193
    {
194
        $this->path = $path;
195
196
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GitContro...tity\ProjectEnvironment which is incompatible with the documented return type VersionControl\GitControlBundle\Entity\Project.
Loading history...
197
    }
198
199
    /**
200
     * Get path.
201
     *
202
     * @return string
203
     */
204
    public function getPath()
205
    {
206
        return $this->path;
207
    }
208
209
    /**
210
     * Get id.
211
     *
212
     * @return int
213
     */
214
    public function getId()
215
    {
216
        return $this->id;
217
    }
218
219
    /**
220
     * Get SSH value.
221
     *
222
     * @return bool
223
     */
224
    public function getSsh(): bool
225
    {
226
        return $this->ssh ?? false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->ssh ?? false could return the type string which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
227
    }
228
229
    /**
230
     * Set to use SSH.
231
     *
232
     * @param bool $ssh
233
     */
234
    public function setSsh(bool $ssh)
235
    {
236
        $this->ssh = $ssh;
0 ignored issues
show
Documentation Bug introduced by
The property $ssh was declared of type string, but $ssh is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
237
    }
238
239
    /**
240
     * Get SSH host.
241
     *
242
     * @return string
243
     */
244
    public function getHost()
245
    {
246
        return $this->host;
247
    }
248
249
    /**
250
     * Set SSH host.
251
     *
252
     * @param string $host
253
     */
254
    public function setHost($host)
255
    {
256
        $this->host = $host;
257
    }
258
259
    /**
260
     * Get SSH username.
261
     *
262
     * @return string
263
     */
264
    public function getUsername()
265
    {
266
        return $this->username;
267
    }
268
269
    /**
270
     * set SSH username.
271
     *
272
     * @param type $username
0 ignored issues
show
Bug introduced by
The type VersionControl\GitControlBundle\Entity\type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
273
     */
274
    public function setUsername($username)
275
    {
276
        $this->username = $username;
277
    }
278
279
    /**
280
     * Get SSH password.
281
     *
282
     * @return string
283
     */
284
    public function getPassword()
285
    {
286
        return $this->password;
287
    }
288
289
    /**
290
     * Set SSH password.
291
     *
292
     * @param string $password
293
     */
294
    public function setPassword($password)
295
    {
296
        if (!is_null($password)) {
0 ignored issues
show
introduced by
The condition is_null($password) is always false.
Loading history...
297
            $this->password = $password;
298
        }
299
    }
300
301
    /**
302
     * Set project.
303
     *
304
     * @param \VersionControl\GitControlBundle\Entity\Project $project
305
     *
306
     * @return Issue
307
     */
308
    public function setProject(\VersionControl\GitControlBundle\Entity\Project $project = null)
309
    {
310
        $this->project = $project;
311
312
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GitContro...tity\ProjectEnvironment which is incompatible with the documented return type VersionControl\GitControlBundle\Entity\Issue.
Loading history...
313
    }
314
315
    /**
316
     * Get project.
317
     *
318
     * @return \VersionControl\GitControlBundle\Entity\Project
319
     */
320
    public function getProject()
321
    {
322
        return $this->project;
323
    }
324
325
    public function getProjectEnvironmentFilePerm()
326
    {
327
        return $this->projectEnvironmentFilePerm;
328
    }
329
330
    public function setProjectEnvironmentFilePerm(\VersionControl\GitControlBundle\Entity\ProjectEnvironmentFilePerm $projectEnvironmentFilePerm)
331
    {
332
        $this->projectEnvironmentFilePerm = $projectEnvironmentFilePerm;
333
334
        return $this;
335
    }
336
337
    /**
338
     * Sets Git Clone Location.
339
     *
340
     * @return string
341
     */
342
    public function getGitCloneLocation()
343
    {
344
        return $this->gitCloneLocation;
345
    }
346
347
    /**
348
     * Gets Git Clone Location.
349
     *
350
     * @param string $gitCloneLocation
351
     *
352
     * @return \VersionControl\GitControlBundle\Entity\ProjectEnvironment
353
     */
354
    public function setGitCloneLocation($gitCloneLocation)
355
    {
356
        $this->gitCloneLocation = $gitCloneLocation;
357
358
        return $this;
359
    }
360
361
    /**
362
     * Get Private Key.
363
     *
364
     * @return string
365
     */
366
    public function getPrivateKey()
367
    {
368
        return $this->privateKey;
369
    }
370
371
    /**
372
     * Get Private Key Password.
373
     *
374
     * @return string
375
     */
376
    public function getPrivateKeyPassword()
377
    {
378
        return $this->privateKeyPassword;
379
    }
380
381
    /**
382
     * Set Private Key.
383
     *
384
     * @param string $privateKey
385
     *
386
     * @return \VersionControl\GitControlBundle\Entity\ProjectEnvironment
387
     */
388
    public function setPrivateKey($privateKey)
389
    {
390
        if (!is_null($privateKey)) {
0 ignored issues
show
introduced by
The condition is_null($privateKey) is always false.
Loading history...
391
            $this->privateKey = $privateKey;
392
        }
393
394
        return $this;
395
    }
396
397
    /**
398
     * Set Private Key Password.
399
     *
400
     * @param type $privateKeyPassword
401
     *
402
     * @return \VersionControl\GitControlBundle\Entity\ProjectEnvironment
403
     */
404
    public function setPrivateKeyPassword($privateKeyPassword)
405
    {
406
        if (!is_null($privateKeyPassword)) {
407
            $this->privateKeyPassword = $privateKeyPassword;
408
        }
409
410
        return $this;
411
    }
412
413
    public function getPort()
414
    {
415
        return 22;
416
    }
417
418
    /**
419
     * Set position.
420
     *
421
     * @param int $position
422
     *
423
     * @return ThreadPage
0 ignored issues
show
Bug introduced by
The type VersionControl\GitControlBundle\Entity\ThreadPage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
424
     */
425
    public function setPosition($position)
426
    {
427
        $this->position = $position;
428
429
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GitContro...tity\ProjectEnvironment which is incompatible with the documented return type VersionControl\GitControlBundle\Entity\ThreadPage.
Loading history...
430
    }
431
432
    /**
433
     * Get position.
434
     *
435
     * @return int
436
     */
437
    public function getPosition()
438
    {
439
        return $this->position;
440
    }
441
}
442