Add methods to retrieve and check existence of information fields in Peer
This commit is contained in:
parent
3d9f5fc6b1
commit
4f9cc89cb8
1 changed files with 30 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use InvalidArgumentException;
|
||||
use Socialbox\Enums\Flags\PeerFlags;
|
||||
use Socialbox\Enums\Types\InformationFieldName;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Objects\Database\PeerInformationFieldRecord;
|
||||
use Socialbox\Objects\PeerAddress;
|
||||
|
@ -119,6 +120,35 @@
|
|||
return $this->informationFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the information field associated with the peer.
|
||||
*
|
||||
* @param InformationFieldName $name The name of the information field to retrieve.
|
||||
* @return InformationField|null The information field associated with the peer.
|
||||
*/
|
||||
public function getInformationField(InformationFieldName $name): ?InformationField
|
||||
{
|
||||
foreach($this->informationFields as $field)
|
||||
{
|
||||
if($field->getName() == $name)
|
||||
{
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the information field exists.
|
||||
*
|
||||
* @param InformationFieldName $name The name of the information field to check.
|
||||
* @return bool True if the information field exists, false otherwise.
|
||||
*/
|
||||
public function informationFieldExists(InformationFieldName $name): bool
|
||||
{
|
||||
return $this->getInformationField($name) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the flags associated with the entity.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue