Skip to content

Commit

Permalink
[Core] Fix static PSCID generation (#5281)
Browse files Browse the repository at this point in the history
[Core] Fix static PSCID generation
  • Loading branch information
ridz1208 committed Oct 7, 2019
1 parent 20ae3f6 commit 66fe2a5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions php/libraries/SiteIDGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class SiteIDGenerator extends IdentifierGenerator
* Creates a new instance of a SiteIDGenerator to create either PSCIDs or
* ExternalIDs. Relevant properties are extracted from the config.xml file.
*
* @param ?string $prefix To be appended to the ID value. Usually an
* @param ?string $siteAbbrevPrefix To be appended to the ID value. Usually an
* abbreviation for the name of a site.
*
* @return void
*/
public function __construct(?string $prefix = null)
public function __construct(?string $siteAbbrevPrefix = null)
{
// Read config settings from project/config.xml to retrieve the
// alphabet, length, and generation method (sequential or random) used
Expand All @@ -48,14 +48,15 @@ public function __construct(?string $prefix = null)
// Initialize minimum and maximum allowed values for IDs. Set the values
// to the lowest/highest character in $alphabet repeated $length times
// if the min or max is not configured in project/config.xml
$this->minValue = $this->_getIDSetting('min') ??
$this->minValue = $this->_getIDSetting('min') ??
str_repeat(strval($this->alphabet[0]), $this->length);
$this->maxValue = $this->_getIDSetting('max') ??
$this->maxValue = $this->_getIDSetting('max') ??
str_repeat(
strval($this->alphabet[count($this->alphabet) - 1]),
$this->length
);
$this->prefix = $prefix ?? $this->_getIDSetting('prefix');
$this->siteAbbrev = $siteAbbrevPrefix;
$this->prefix = $this->_getIDSetting('prefix');
$this->validate();
}

Expand Down Expand Up @@ -210,9 +211,8 @@ private function _getIDSetting(
}
} else {
// The other option, 'siteAbbrev', indicates that the calling
// code should prepend a Site Alias to the ID. Since the config
// file does not know what this will be, return null.
return null;
// code should prepend a Site Alias to the ID.
return $this->siteAbbrev;
}
}
// Min, max, and length values should be returned as integers or as
Expand Down

0 comments on commit 66fe2a5

Please sign in to comment.