Skip to content

Commit

Permalink
Use name magicGet for magic getters
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Nov 6, 2023
1 parent b4702a9 commit 1b00c98
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 63 deletions.
44 changes: 22 additions & 22 deletions Classes/Common/AbstractDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ abstract protected function getDocument();
* @return array Array of physical elements' id, type, label and file representations ordered
* by "@ORDER" attribute / IIIF Sequence's Canvases
*/
abstract protected function _getPhysicalStructure(): array;
abstract protected function magicGetPhysicalStructure(): array;

/**
* This returns the smLinks between logical and physical structMap (METS) and models the
Expand All @@ -443,7 +443,7 @@ abstract protected function _getPhysicalStructure(): array;
*
* @return array The links between logical and physical nodes / Range, Manifest and Canvas
*/
abstract protected function _getSmLinks(): array;
abstract protected function magicGetSmLinks(): array;

/**
* This returns the document's thumbnail location
Expand All @@ -456,7 +456,7 @@ abstract protected function _getSmLinks(): array;
*
* @return string The document's thumbnail location
*/
abstract protected function _getThumbnail(bool $forceReload = false): string;
abstract protected function magicGetThumbnail(bool $forceReload = false): string;

/**
* This returns the ID of the toplevel logical structure node
Expand All @@ -467,7 +467,7 @@ abstract protected function _getThumbnail(bool $forceReload = false): string;
*
* @return string The logical structure node's ID
*/
abstract protected function _getToplevelId(): string;
abstract protected function magicGetToplevelId(): string;

/**
* This sets some basic class properties
Expand Down Expand Up @@ -658,7 +658,7 @@ protected function getFullTextFromXml(string $id): string
// Load available text formats, ...
$this->loadFormats();
// ... physical structure ...
$this->_getPhysicalStructure();
$this->magicGetPhysicalStructure();
// ... and extension configuration.
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']);
Expand Down Expand Up @@ -795,10 +795,10 @@ public static function getTitle(int $uid, bool $recursive = false): string
*/
public function getToplevelMetadata(int $cPid = 0): array
{
$toplevelMetadata = $this->getMetadata($this->_getToplevelId(), $cPid);
$toplevelMetadata = $this->getMetadata($this->magicGetToplevelId(), $cPid);
// Add information from METS structural map to toplevel metadata array.
if ($this instanceof MetsDocument) {
$this->addMetadataFromMets($toplevelMetadata, $this->_getToplevelId());
$this->addMetadataFromMets($toplevelMetadata, $this->magicGetToplevelId());
}
// Set record identifier for METS file / IIIF manifest if not present.
if (array_key_exists('record_id', $toplevelMetadata)) {
Expand Down Expand Up @@ -850,7 +850,7 @@ protected function getTreeDepth(array $structure, int $depth, string $logId)
*/
public function getStructureDepth(string $logId)
{
return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId);
return $this->getTreeDepth($this->magicGetTableOfContents(), 1, $logId);
}

/**
Expand Down Expand Up @@ -989,7 +989,7 @@ protected function initializeMetadata(string $format): array {
*
* @return int The PID of the metadata definitions
*/
protected function _getCPid(): int
protected function magicGetCPid(): int

Check notice on line 992 in Classes/Common/AbstractDocument.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Classes/Common/AbstractDocument.php#L992

Protected method name "AbstractDocument::magicGetCPid" is not in camel caps format
{
return $this->cPid;
}
Expand All @@ -1001,7 +1001,7 @@ protected function _getCPid(): int
*
* @return bool Are there any fulltext files available?
*/
protected function _getHasFulltext(): bool
protected function magicGetHasFulltext(): bool
{
$this->ensureHasFulltextIsSet();
return $this->hasFulltext;
Expand All @@ -1014,7 +1014,7 @@ protected function _getHasFulltext(): bool
*
* @return array Array of metadata with their corresponding logical structure node ID as key
*/
protected function _getMetadataArray(): array
protected function magicGetMetadataArray(): array
{
// Set metadata definitions' PID.
$cPid = ($this->cPid ? $this->cPid : $this->pid);
Expand All @@ -1040,9 +1040,9 @@ protected function _getMetadataArray(): array
*
* @return int The total number of pages and/or tracks
*/
protected function _getNumPages(): int
protected function magicGetNumPages(): int
{
$this->_getPhysicalStructure();
$this->magicGetPhysicalStructure();
return $this->numPages;
}

Expand All @@ -1053,7 +1053,7 @@ protected function _getNumPages(): int
*
* @return int The UID of the parent document or zero if not applicable
*/
protected function _getParentId(): int
protected function magicGetParentId(): int
{
return $this->parentId;
}
Expand All @@ -1065,12 +1065,12 @@ protected function _getParentId(): int
*
* @return array Array of elements' type, label and file representations ordered by "@ID" attribute / Canvas order
*/
protected function _getPhysicalStructureInfo(): array
protected function magicGetPhysicalStructureInfo(): array
{
// Is there no physical structure array yet?
if (!$this->physicalStructureLoaded) {
// Build physical structure array.
$this->_getPhysicalStructure();
$this->magicGetPhysicalStructure();
}
return $this->physicalStructureInfo;
}
Expand All @@ -1082,7 +1082,7 @@ protected function _getPhysicalStructureInfo(): array
*
* @return int The PID of the document or zero if not in database
*/
protected function _getPid(): int
protected function magicGetPid(): int
{
return $this->pid;
}
Expand All @@ -1094,7 +1094,7 @@ protected function _getPid(): int
*
* @return bool Is the document instantiated successfully?
*/
protected function _getReady(): bool
protected function magicGetReady(): bool
{
return $this->ready;
}
Expand All @@ -1106,7 +1106,7 @@ protected function _getReady(): bool
*
* @return mixed The METS file's / IIIF manifest's record identifier
*/
protected function _getRecordId()
protected function magicGetRecordId()
{
return $this->recordId;
}
Expand All @@ -1118,7 +1118,7 @@ protected function _getRecordId()
*
* @return int The UID of the root document or zero if not applicable
*/
protected function _getRootId(): int
protected function magicGetRootId(): int
{
if (!$this->rootIdLoaded) {
if ($this->parentId) {
Expand All @@ -1139,7 +1139,7 @@ protected function _getRootId(): int
*
* @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved
*/
protected function _getTableOfContents(): array
protected function magicGetTableOfContents(): array
{
// Is there no logical structure array yet?
if (!$this->tableOfContentsLoaded) {
Expand Down Expand Up @@ -1196,7 +1196,7 @@ protected function __construct(int $pid, string $location, $preloadedDocument, a
*/
public function __get(string $var)
{
$method = '_get' . ucfirst($var);
$method = 'magicGet' . ucfirst($var);
if (
!property_exists($this, $var)
|| !method_exists($this, $method)
Expand Down
24 changes: 12 additions & 12 deletions Classes/Common/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ protected function getUseGroups(string $use)
}

/**
* @see AbstractDocument::_getPhysicalStructure()
* @see AbstractDocument::magicGetPhysicalStructure()
*/
protected function _getPhysicalStructure(): array
protected function magicGetPhysicalStructure(): array
{
// Is there no physical structure array yet?
if (!$this->physicalStructureLoaded) {
Expand Down Expand Up @@ -500,7 +500,7 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool
$details['volume'] = '';
$details['pagination'] = '';
$cPid = ($this->cPid ? $this->cPid : $this->pid);
if ($details['id'] == $this->_getToplevelId()) {
if ($details['id'] == $this->magicGetToplevelId()) {
$metadata = $this->getMetadata($details['id'], $cPid);
if (!empty($metadata['type'][0])) {
$details['type'] = $metadata['type'][0];
Expand All @@ -509,9 +509,9 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool
$details['thumbnailId'] = $resource->getThumbnailUrl();
$details['points'] = '';
// Load structural mapping
$this->_getSmLinks();
$this->magicGetSmLinks();
// Load physical structure.
$this->_getPhysicalStructure();
$this->magicGetPhysicalStructure();
$canvases = [];
if ($resource instanceof ManifestInterface) {
$startCanvas = $resource->getStartCanvasOrFirstCanvas();
Expand Down Expand Up @@ -711,9 +711,9 @@ public function getMetadata(string $id, int $cPid = 0): array
}

/**
* @see AbstractDocument::_getSmLinks()
* @see AbstractDocument::magicGetSmLinks()
*/
protected function _getSmLinks(): array
protected function magicGetSmLinks(): array
{
if (!$this->smLinksLoaded && isset($this->iiif) && $this->iiif instanceof ManifestInterface) {
if (!empty($this->iiif->getDefaultCanvases())) {
Expand Down Expand Up @@ -788,7 +788,7 @@ public function getFullText(string $id): string
$this->ensureHasFulltextIsSet();
if ($this->hasFulltext) {
// Load physical structure ...
$this->_getPhysicalStructure();
$this->magicGetPhysicalStructure();
// ... and extension configuration.
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']);
Expand Down Expand Up @@ -940,17 +940,17 @@ protected function ensureHasFulltextIsSet(): void
}

/**
* @see AbstractDocument::_getThumbnail()
* @see AbstractDocument::magicGetThumbnail()
*/
protected function _getThumbnail(bool $forceReload = false): string
protected function magicGetThumbnail(bool $forceReload = false): string
{
return $this->iiif->getThumbnailUrl();
}

/**
* @see AbstractDocument::_getToplevelId()
* @see AbstractDocument::magicGetToplevelId()
*/
protected function _getToplevelId(): string
protected function magicGetToplevelId(): string
{
if (empty($this->toplevelId)) {
if (isset($this->iiif)) {
Expand Down
Loading

0 comments on commit 1b00c98

Please sign in to comment.