Repository   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 84
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 3 1
A getType() 0 3 1
A setType() 0 5 1
A getUrl() 0 3 1
A setUrl() 0 5 1
A getId() 0 3 1
1
<?php
2
3
namespace App\Satis\Model;
4
5
use App\Satis\ConfigManager;
6
use JMS\Serializer\Annotation\Type;
7
8
/**
9
* Repository class
10
*
11
* Represent a composer repository definition
12
* @author Lukas Homza <[email protected]>
13
*/
14
class Repository {
15
16
  const REGEX = '#((git|ssh|http(s)?)|(git@[\w.]+))(:(\/\/)?)([\w.@:\/\-~]+)(\/)?#';
17
18
  /**
19
   * @Type("string")
20
   */
21
  private $type;
22
23
  /**
24
   * @Type("string")
25
   */
26
  private $url;
27
28
  /**
29
   * Initialize with default opinionated values
30
   */
31
  public function __construct() {
32
    $this->type = config('satis.default_repository_type');
33
    $this->url = '';
34
  }
35
36
  /**
37
   * Get the string representation
38
   *
39
   * @return string
40
   */
41
  public function __toString() {
42
    return $this->url;
43
  }
44
45
  /**
46
   * Get type
47
   *
48
   * @return string $type
49
   */
50
  public function getType() {
51
    return $this->type;
52
  }
53
54
  /**
55
   * Set type
56
   *
57
   * @param string $type
58
   *
59
   * @return static
60
   */
61
  public function setType($type) {
62
    $this->type = strtolower($type);
63
64
    return $this;
65
  }
66
67
  /**
68
   * Get url
69
   *
70
   * @return string $url
71
   */
72
  public function getUrl() {
73
    return $this->url;
74
  }
75
76
  /**
77
   * Set url
78
   *
79
   * @param string $url
80
   *
81
   * @return static
82
   */
83
  public function setUrl($url) {
84
    $this->url = urldecode($url);
85
86
    return $this;
87
  }
88
89
  /**
90
   * Get repository ID
91
   *
92
   * @return string
93
   */
94
  public function getId() {
95
    return ConfigManager::nameToId($this->url);
96
  }
97
}
98