oreolek
/
news-script
Archived
1
0
Fork 0
This repository has been archived on 2020-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
news-script/src/Publisher.php

28 lines
514 B
PHP

<?php
namespace Oreolek;
abstract class Publisher {
protected $dry_run = true;
public function __construct($config) {
$this->dry_run = $config['DRY_RUN'];
}
abstract protected function _publish(string $text);
public function publish(string $text): void {
if (empty($this->client)) {
return;
}
try {
$this->_publish($text);
} catch (\Exception $e) {
echo $e;
return;
}
if (!$this->dry_run) {
file_put_contents('.lastrun', time());
}
}
}