Skip to content

Commit

Permalink
Add php-cs-fixer rule for ordered class elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Aug 31, 2023
1 parent 21602f2 commit 0ebd1e4
Show file tree
Hide file tree
Showing 16 changed files with 755 additions and 754 deletions.
30 changes: 15 additions & 15 deletions src/RecordManager/Base/Command/Records/Deduplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ class Deduplicate extends AbstractBase
*/
protected $terminate = false;

/**
* Catch the SIGINT signal and signal the main thread to terminate
*
* Note: this needs to be public so that the int handler can call it.
*
* @param int $signal Signal ID
*
* @return void
*/
public function sigIntHandler($signal)
{
$this->terminate = true;
$this->logger->writelnConsole('Termination requested');
}

/**
* Configure the command.
*
Expand Down Expand Up @@ -297,19 +312,4 @@ function ($record) use (
$this->logger->logInfo('deduplicate', 'Deduplication completed');
return Command::SUCCESS;
}

/**
* Catch the SIGINT signal and signal the main thread to terminate
*
* Note: this needs to be public so that the int handler can call it.
*
* @param int $signal Signal ID
*
* @return void
*/
public function sigIntHandler($signal)
{
$this->terminate = true;
$this->logger->writelnConsole('Termination requested');
}
}
46 changes: 23 additions & 23 deletions src/RecordManager/Base/Command/Records/Harvest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ public function __construct(
$this->harvesterPluginManager = $harvesterManager;
}

/**
* Mark a record "seen". Used by OAI-PMH harvesting when deletions are not
* supported.
*
* @param string $sourceId Source ID
* @param string $oaiId ID of the record as received from OAI-PMH
* @param bool $deleted Whether the record is to be deleted
*
* @throws \Exception
* @return void
*/
public function markRecordSeen($sourceId, $oaiId, $deleted)
{
if ($deleted) {
// Don't mark deleted records...
return;
}
$this->db->updateRecords(
['source_id' => $sourceId, 'oai_id' => $oaiId],
['date' => $this->db->getTimestamp()]
);
}

/**
* Configure the command.
*
Expand Down Expand Up @@ -419,29 +442,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output)
return $returnCode;
}

/**
* Mark a record "seen". Used by OAI-PMH harvesting when deletions are not
* supported.
*
* @param string $sourceId Source ID
* @param string $oaiId ID of the record as received from OAI-PMH
* @param bool $deleted Whether the record is to be deleted
*
* @throws \Exception
* @return void
*/
public function markRecordSeen($sourceId, $oaiId, $deleted)
{
if ($deleted) {
// Don't mark deleted records...
return;
}
$this->db->updateRecords(
['source_id' => $sourceId, 'oai_id' => $oaiId],
['date' => $this->db->getTimestamp()]
);
}

/**
* Set deleted all records that were not "seen" during harvest
*
Expand Down
42 changes: 21 additions & 21 deletions src/RecordManager/Base/Database/PDODatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,27 @@ public function getRecordAttrs(string $collection, string $id): array
return $attrs;
}

/**
* Get database handle
*
* @return \PDO
*/
public function getDb(): \PDO
{
if (null === $this->db) {
$this->db = new \PDO($this->dsn, $this->username, $this->password);
$this->db
->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
$this->pid = getmypid();
} elseif ($this->pid !== getmypid()) {
throw new \Exception(
'PID ' . getmypid() . ': database already connected by PID '
. $this->pid
);
}
return $this->db;
}

/**
* Get a record
*
Expand Down Expand Up @@ -1194,25 +1215,4 @@ protected function getMainFields(string $collection): array
}
return $this->mainFields[$collection];
}

/**
* Get database handle
*
* @return \PDO
*/
public function getDb(): \PDO
{
if (null === $this->db) {
$this->db = new \PDO($this->dsn, $this->username, $this->password);
$this->db
->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
$this->pid = getmypid();
} elseif ($this->pid !== getmypid()) {
throw new \Exception(
'PID ' . getmypid() . ': database already connected by PID '
. $this->pid
);
}
return $this->db;
}
}
28 changes: 14 additions & 14 deletions src/RecordManager/Base/Harvest/GeniePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,6 @@ public function setInitialPosition($pos)
$this->startPosition = intval($pos);
}

/**
* Reformat a date for use in API queries
*
* @param string $date Date in YYYY-MM-DD format
*
* @return string Date in MM/DD/YYYY format.
*
* @psalm-suppress FalsableReturnStatement
*/
protected function reformatDate($date)
{
return date('n/j/Y', strtotime($date));
}

/**
* Harvest all available documents.
*
Expand Down Expand Up @@ -348,6 +334,20 @@ public function harvest($callback)
}
}

/**
* Reformat a date for use in API queries
*
* @param string $date Date in YYYY-MM-DD format
*
* @return string Date in MM/DD/YYYY format.
*
* @psalm-suppress FalsableReturnStatement
*/
protected function reformatDate($date)
{
return date('n/j/Y', strtotime($date));
}

/**
* Get server date as a unix timestamp
*
Expand Down
40 changes: 20 additions & 20 deletions src/RecordManager/Base/Record/Ead3.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,26 @@ public function getRawGeographicTopicIds(): array
return [];
}

/**
* Get author identifiers
*
* @return array
*/
public function getAuthorIds(): array
{
return [];
}

/**
* Get corporate author identifiers
*
* @return array<int, string>
*/
public function getCorporateAuthorIds()
{
return [];
}

/**
* Get topic identifiers.
*
Expand Down Expand Up @@ -286,26 +306,6 @@ protected function getAuthors()
return $result;
}

/**
* Get author identifiers
*
* @return array
*/
public function getAuthorIds(): array
{
return [];
}

/**
* Get corporate author identifiers
*
* @return array<int, string>
*/
public function getCorporateAuthorIds()
{
return [];
}

/**
* Get corporate authors
*
Expand Down
64 changes: 32 additions & 32 deletions src/RecordManager/Base/Record/Forward.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,38 @@ public function getMainAuthor()
return $author;
}

/**
* Return record title
*
* @param bool $forFiling Whether the title is to be used in filing
* (e.g. sorting, non-filing characters should be removed)
*
* @return string
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getTitle($forFiling = false)
{
$doc = $this->getMainElement();
$title = (string)$doc->IdentifyingTitle;

if ($forFiling) {
$title = $this->metadataUtils->createSortTitle($title);
}

return $title;
}

/**
* Return format from predefined values
*
* @return string|array
*/
public function getFormat()
{
return 'MotionPicture';
}

/**
* Get the main metadata element
*
Expand Down Expand Up @@ -425,38 +457,6 @@ protected function getDescriptions($language = null)
return $results;
}

/**
* Return record title
*
* @param bool $forFiling Whether the title is to be used in filing
* (e.g. sorting, non-filing characters should be removed)
*
* @return string
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getTitle($forFiling = false)
{
$doc = $this->getMainElement();
$title = (string)$doc->IdentifyingTitle;

if ($forFiling) {
$title = $this->metadataUtils->createSortTitle($title);
}

return $title;
}

/**
* Return format from predefined values
*
* @return string|array
*/
public function getFormat()
{
return 'MotionPicture';
}

/**
* Return genres
*
Expand Down
40 changes: 20 additions & 20 deletions src/RecordManager/Base/Record/Lrmi.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ public function getMainAuthor()
return $authors[0] ?? '';
}

/**
* Get topics.
*
* @return array
*/
public function getTopics()
{
return $this->getTopicData(false);
}

/**
* Get all topic identifiers (for enrichment)
*
* @return array
*/
public function getRawTopicIds(): array
{
return $this->getTopicData(true);
}

/**
* Get primary authors
*
Expand Down Expand Up @@ -159,26 +179,6 @@ protected function getCorporateAuthors()
return $result;
}

/**
* Get topics.
*
* @return array
*/
public function getTopics()
{
return $this->getTopicData(false);
}

/**
* Get all topic identifiers (for enrichment)
*
* @return array
*/
public function getRawTopicIds(): array
{
return $this->getTopicData(true);
}

/**
* Get topics with value or id.
*
Expand Down
Loading

0 comments on commit 0ebd1e4

Please sign in to comment.