1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00
Arsse/lib/Service/Serial/Driver.php

46 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
2021-04-14 15:17:01 +00:00
namespace JKingWeb\Arsse\Service\Serial;
2017-08-29 14:50:31 +00:00
use JKingWeb\Arsse\Arsse;
class Driver implements \JKingWeb\Arsse\Service\Driver {
protected $queue = [];
2018-10-26 18:58:04 +00:00
2017-08-29 14:50:31 +00:00
public static function driverName(): string {
return Arsse::$lang->msg("Driver.Service.Serial.Name");
}
2017-08-29 14:50:31 +00:00
public static function requirementsMet(): bool {
// this driver has no requirements
return true;
}
2018-10-26 18:58:04 +00:00
2017-08-29 14:50:31 +00:00
public function __construct() {
}
2017-08-29 14:50:31 +00:00
public function queue(int ...$feeds): int {
$this->queue = array_merge($this->queue, $feeds);
return sizeof($this->queue);
}
2017-08-29 14:50:31 +00:00
public function exec(): int {
while (sizeof($this->queue)) {
$id = array_shift($this->queue);
2022-12-30 17:41:12 +00:00
Arsse::$db->subscriptionUpdate(null, $id);
}
return Arsse::$conf->serviceQueueWidth - sizeof($this->queue);
}
2019-10-19 22:51:01 +00:00
public function clean(): int {
$out = sizeof($this->queue);
$this->queue = [];
2019-10-19 22:51:01 +00:00
return $out;
}
2017-08-29 14:50:31 +00:00
}