Source of file Identifier.php
Size: 1,917 Bytes - Last Modified: 2021-12-24T06:51:36+00:00
/var/www/docs.ssmods.com/process/src/src/Identifier/Identifier.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | <?php namespace Heystack\Core\Identifier; /** * Class Identifier * @author Cam Spiers <cameron@heyday.co.nz> * @package Heystack\Core\Identifier */ class Identifier implements IdentifierInterface { /** * The glue to use for preparing the secondary identifiers */ const GLUE = '.'; /** * @var */ protected $primary; /** * @var array */ protected $secondaries = []; /** * @param string $primary * @param array|void $secondaries */ public function __construct($primary, array $secondaries = null) { $this->primary = $primary; if (is_array($secondaries)) { $this->secondaries = $secondaries; } } /** * @return string */ public function getPrimary() { return $this->primary; } /** * @return array */ public function getSecondaries() { return $this->secondaries; } /** * @return string */ public function getFull() { if (count($this->secondaries)) { return implode( self::GLUE, array_merge( [$this->primary], $this->secondaries ) ); } return $this->primary; } /** * @return string */ public function __toString() { return $this->getFull(); } /** * @param IdentifierInterface $identifier * @return bool */ public function isMatch(IdentifierInterface $identifier) { return $this->primary === $identifier->getPrimary(); } /** * @param IdentifierInterface $identifier * @return bool */ public function isMatchStrict(IdentifierInterface $identifier) { return $this->isMatch($identifier) && $this->secondaries === $identifier->getSecondaries(); } } |