Changed indentation and added type hints
This commit is contained in:
@@ -31,7 +31,7 @@ class COIDParser {
|
|||||||
* @param string $coidString A COID string.
|
* @param string $coidString A COID string.
|
||||||
* @return IRI
|
* @return IRI
|
||||||
*/
|
*/
|
||||||
public static function fromString($coidString) {
|
public static function fromString($coidString) : IRI {
|
||||||
$coidPre = new IRI(
|
$coidPre = new IRI(
|
||||||
(strtolower(substr($coidString, 0, 7)) == 'coid://') ? $coidString : 'coid://'.$coidString
|
(strtolower(substr($coidString, 0, 7)) == 'coid://') ? $coidString : 'coid://'.$coidString
|
||||||
);
|
);
|
||||||
@@ -45,7 +45,7 @@ class COIDParser {
|
|||||||
* @param IRI $coid
|
* @param IRI $coid
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public static function getType(IRI $coid) {
|
public static function getType(IRI $coid) : ?int {
|
||||||
if ($coid->getScheme()!='coid' || $coid->getHost()==''
|
if ($coid->getScheme()!='coid' || $coid->getHost()==''
|
||||||
|| preg_match(self::REGEX_HOSTNAME, $coid->getHost()) != 1)
|
|| preg_match(self::REGEX_HOSTNAME, $coid->getHost()) != 1)
|
||||||
return self::COID_INVALID;
|
return self::COID_INVALID;
|
||||||
@@ -79,9 +79,9 @@ class COIDParser {
|
|||||||
* Checks whether the given IRI object is a valid COID.
|
* Checks whether the given IRI object is a valid COID.
|
||||||
*
|
*
|
||||||
* @param IRI $coid
|
* @param IRI $coid
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isValidCOID(IRI $coid) {
|
public static function isValidCOID(IRI $coid) : bool {
|
||||||
return (self::getType($coid)!=self::COID_INVALID);
|
return (self::getType($coid)!=self::COID_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ class COIDParser {
|
|||||||
* @param IRI $coid
|
* @param IRI $coid
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getName(IRI $coid) {
|
public static function getName(IRI $coid) : ?string {
|
||||||
if (self::getType($coid)!=self::COID_INVALID
|
if (self::getType($coid)!=self::COID_INVALID
|
||||||
&& self::getType($coid)!=self::COID_ROOT) {
|
&& self::getType($coid)!=self::COID_ROOT) {
|
||||||
$segments = explode('/', $coid->getPath());
|
$segments = explode('/', $coid->getPath());
|
||||||
@@ -106,7 +106,7 @@ class COIDParser {
|
|||||||
* @param IRI $coid
|
* @param IRI $coid
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getVersion(IRI $coid) {
|
public static function getVersion(IRI $coid) : ?string {
|
||||||
if (self::getType($coid)==self::COID_VERSIONED) {
|
if (self::getType($coid)==self::COID_VERSIONED) {
|
||||||
$segments = explode('/', $coid->getPath());
|
$segments = explode('/', $coid->getPath());
|
||||||
return $segments[2];
|
return $segments[2];
|
||||||
@@ -121,7 +121,7 @@ class COIDParser {
|
|||||||
* @param IRI $coid
|
* @param IRI $coid
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function getVersionWildcard(IRI $coid) {
|
public static function getVersionWildcard(IRI $coid) : ?string {
|
||||||
if (self::getType($coid)==self::COID_VERSION_WILDCARD) {
|
if (self::getType($coid)==self::COID_VERSION_WILDCARD) {
|
||||||
$segments = explode('/', $coid->getPath());
|
$segments = explode('/', $coid->getPath());
|
||||||
return $segments[2];
|
return $segments[2];
|
||||||
@@ -136,7 +136,7 @@ class COIDParser {
|
|||||||
* @param IRI $coid
|
* @param IRI $coid
|
||||||
* @return IRI|null
|
* @return IRI|null
|
||||||
*/
|
*/
|
||||||
public static function getNamespaceCOID(IRI $coid) {
|
public static function getNamespaceCOID(IRI $coid) : ?IRI {
|
||||||
switch (self::getType($coid)) {
|
switch (self::getType($coid)) {
|
||||||
case self::COID_ROOT:
|
case self::COID_ROOT:
|
||||||
return $coid;
|
return $coid;
|
||||||
|
|||||||
Reference in New Issue
Block a user