mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-06-24 14:18:48 +02:00
Reformat codebase v4 (#2872)
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
parent
66568e3a39
commit
4f75591060
398 changed files with 58607 additions and 56442 deletions
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
|
||||
* Atom feeds for websites that don't have one.
|
||||
|
@ -6,9 +7,9 @@
|
|||
* For the full license information, please view the UNLICENSE file distributed
|
||||
* with this source code.
|
||||
*
|
||||
* @package Core
|
||||
* @license http://unlicense.org/ UNLICENSE
|
||||
* @link https://github.com/rss-bridge/rss-bridge
|
||||
* @package Core
|
||||
* @license http://unlicense.org/ UNLICENSE
|
||||
* @link https://github.com/rss-bridge/rss-bridge
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -20,8 +21,9 @@
|
|||
* @link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes List of HTTP
|
||||
* status codes
|
||||
*/
|
||||
function returnError($message, $code){
|
||||
throw new \Exception($message, $code);
|
||||
function returnError($message, $code)
|
||||
{
|
||||
throw new \Exception($message, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,8 +31,9 @@ function returnError($message, $code){
|
|||
*
|
||||
* @param string $message The error message
|
||||
*/
|
||||
function returnClientError($message){
|
||||
returnError($message, 400);
|
||||
function returnClientError($message)
|
||||
{
|
||||
returnError($message, 400);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,8 +41,9 @@ function returnClientError($message){
|
|||
*
|
||||
* @param string $message The error message
|
||||
*/
|
||||
function returnServerError($message){
|
||||
returnError($message, 500);
|
||||
function returnServerError($message)
|
||||
{
|
||||
returnError($message, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,27 +54,28 @@ function returnServerError($message){
|
|||
*
|
||||
* @return int The total number the same error has appeared
|
||||
*/
|
||||
function logBridgeError($bridgeName, $code) {
|
||||
$cacheFac = new CacheFactory();
|
||||
function logBridgeError($bridgeName, $code)
|
||||
{
|
||||
$cacheFac = new CacheFactory();
|
||||
|
||||
$cache = $cacheFac->create(Configuration::getConfig('cache', 'type'));
|
||||
$cache->setScope('error_reporting');
|
||||
$cache->setkey($bridgeName . '_' . $code);
|
||||
$cache->purgeCache(86400); // 24 hours
|
||||
$cache = $cacheFac->create(Configuration::getConfig('cache', 'type'));
|
||||
$cache->setScope('error_reporting');
|
||||
$cache->setkey($bridgeName . '_' . $code);
|
||||
$cache->purgeCache(86400); // 24 hours
|
||||
|
||||
if($report = $cache->loadData()) {
|
||||
$report = json_decode($report, true);
|
||||
$report['time'] = time();
|
||||
$report['count']++;
|
||||
} else {
|
||||
$report = array(
|
||||
'error' => $code,
|
||||
'time' => time(),
|
||||
'count' => 1,
|
||||
);
|
||||
}
|
||||
if ($report = $cache->loadData()) {
|
||||
$report = json_decode($report, true);
|
||||
$report['time'] = time();
|
||||
$report['count']++;
|
||||
} else {
|
||||
$report = [
|
||||
'error' => $code,
|
||||
'time' => time(),
|
||||
'count' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
$cache->saveData(json_encode($report));
|
||||
$cache->saveData(json_encode($report));
|
||||
|
||||
return $report['count'];
|
||||
return $report['count'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue