update libraries and run php-cs-fixer.

This commit is contained in:
Yoshihiro OKUMURA 2024-01-30 18:35:21 +09:00
parent b2617cd48c
commit 0e188c0380
8 changed files with 440 additions and 628 deletions

@ -15,15 +15,15 @@
} }
}, },
"require": { "require": {
"php": ">=8.0", "php": ">=8.2",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-rrd": "*", "ext-rrd": "*",
"phpmailer/phpmailer": "^6.6", "phpmailer/phpmailer": "^6.9",
"twig/twig": "^3.4" "twig/twig": "^3.8"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3.8" "friendsofphp/php-cs-fixer": "^3.48"
}, },
"license": "MIT", "license": "MIT",
"authors": [ "authors": [

967
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -97,32 +97,32 @@ class DigiTemp
$key = array_shift($cols); $key = array_shift($cols);
$value = array_shift($cols); $value = array_shift($cols);
switch ($key) { switch ($key) {
case 'TTY': case 'TTY':
$this->config[$key] = $value; $this->config[$key] = $value;
break; break;
case 'READ_TIME': case 'READ_TIME':
$this->config[$key] = (int) $value; $this->config[$key] = (int) $value;
break; break;
case 'LOG_TYPE': case 'LOG_TYPE':
$this->config[$key] = (int) $value; $this->config[$key] = (int) $value;
break; break;
case 'LOG_FORMAT': case 'LOG_FORMAT':
$this->config[$key] = '"' === substr($value, 0, 1) ? stripslashes(substr($value, 1, -1)) : $value; $this->config[$key] = '"' === substr($value, 0, 1) ? stripslashes(substr($value, 1, -1)) : $value;
break; break;
case 'CNT_FORMAT': case 'CNT_FORMAT':
$this->config[$key] = '"' === substr($value, 0, 1) ? stripslashes(substr($value, 1, -1)) : $value; $this->config[$key] = '"' === substr($value, 0, 1) ? stripslashes(substr($value, 1, -1)) : $value;
break; break;
case 'HUM_FORMAT': case 'HUM_FORMAT':
$this->config[$key] = '"' === substr($value, 0, 1) ? stripslashes(substr($value, 1, -1)) : $value; $this->config[$key] = '"' === substr($value, 0, 1) ? stripslashes(substr($value, 1, -1)) : $value;
break; break;
case 'SENSORS': case 'SENSORS':
$this->config[$key] = (int) $value; $this->config[$key] = (int) $value;
break; break;
case 'ROM': case 'ROM':
$this->config[$key][(int) $value] = str_replace('0x', '', implode('', array_reverse($cols))); $this->config[$key][(int) $value] = str_replace('0x', '', implode('', array_reverse($cols)));
break; break;
default: default:
return false; return false;
} }
} }

@ -58,8 +58,6 @@ class Address
/** /**
* check wheter string is email. * check wheter string is email.
* *
* @param string $text email
*
* @return bool false if not email string * @return bool false if not email string
*/ */
public function validateEmail(string $email): bool public function validateEmail(string $email): bool

@ -9,10 +9,9 @@ class UTF8_Mailer
/** /**
* send mail. * send mail.
* *
* @param Address $form from email address * @param array $tos to email addresses
* @param array $tos to email addresses * @param string $subject subject
* @param string $subject subject * @param string $body mail body
* @param string $body mail body
* *
* @return bool false if failure * @return bool false if failure
*/ */

@ -6,8 +6,8 @@ require_once APPDIR.'/vendor/autoload.php';
$config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true); $config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true);
$digitemp = new \Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']); $digitemp = new Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']);
$rrdtemp = new \Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']); $rrdtemp = new Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']);
$num = $digitemp->getNumSensors(); $num = $digitemp->getNumSensors();
$sensors = []; $sensors = [];
for ($i = 0; $i < $num; ++$i) { for ($i = 0; $i < $num; ++$i) {
@ -29,8 +29,8 @@ if ($do_send) {
$from_name = $config['mail_from_name']; $from_name = $config['mail_from_name'];
$to = $config['mail_alert_to']; $to = $config['mail_alert_to'];
$subject = $config['mail_alert_subject']; $subject = $config['mail_alert_subject'];
$loader = new \Twig\Loader\FilesystemLoader(APPDIR.'/'.$config['templates_dir']); $loader = new Twig\Loader\FilesystemLoader(APPDIR.'/'.$config['templates_dir']);
$twig = new \Twig\Environment($loader); $twig = new Twig\Environment($loader);
$data = [ $data = [
'range' => [ 'range' => [
'upper' => $upper, 'upper' => $upper,
@ -45,7 +45,7 @@ if ($do_send) {
]; ];
$body = $twig->render($config['mail_alert_template'], $data); $body = $twig->render($config['mail_alert_template'], $data);
$from = new \Orrisroot\Mail\Address($from_name, $from); $from = new Orrisroot\Mail\Address($from_name, $from);
$tos = [new \Orrisroot\Mail\Address($to, $to)]; $tos = [new Orrisroot\Mail\Address($to, $to)];
\Orrisroot\Mail\UTF8_Mailer::sendMail($from, $tos, $subject, $body); Orrisroot\Mail\UTF8_Mailer::sendMail($from, $tos, $subject, $body);
} }

@ -6,8 +6,8 @@ require_once APPDIR.'/vendor/autoload.php';
$config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true); $config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true);
$digitemp = new \Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']); $digitemp = new Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']);
$rrdtemp = new \Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']); $rrdtemp = new Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']);
$num = $digitemp->getNumSensors(); $num = $digitemp->getNumSensors();
$sensors = []; $sensors = [];
for ($i = 0; $i < $num; ++$i) { for ($i = 0; $i < $num; ++$i) {
@ -20,8 +20,8 @@ $from = $config['mail_from'];
$from_name = $config['mail_from_name']; $from_name = $config['mail_from_name'];
$to = $config['mail_info_to']; $to = $config['mail_info_to'];
$subject = $config['mail_info_subject']; $subject = $config['mail_info_subject'];
$loader = new \Twig\Loader\FilesystemLoader(APPDIR.'/'.$config['templates_dir']); $loader = new Twig\Loader\FilesystemLoader(APPDIR.'/'.$config['templates_dir']);
$twig = new \Twig\Environment($loader); $twig = new Twig\Environment($loader);
$data = [ $data = [
'from' => [ 'from' => [
'name' => $from_name, 'name' => $from_name,
@ -32,6 +32,6 @@ $data = [
]; ];
$body = $twig->render($config['mail_info_template'], $data); $body = $twig->render($config['mail_info_template'], $data);
$from = new \Orrisroot\Mail\Address($from_name, $from); $from = new Orrisroot\Mail\Address($from_name, $from);
$tos = [new \Orrisroot\Mail\Address($to, $to)]; $tos = [new Orrisroot\Mail\Address($to, $to)];
\Orrisroot\Mail\UTF8_Mailer::sendMail($from, $tos, $subject, $body); Orrisroot\Mail\UTF8_Mailer::sendMail($from, $tos, $subject, $body);

@ -6,8 +6,8 @@ require_once APPDIR.'/vendor/autoload.php';
$config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true); $config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true);
$digitemp = new \Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']); $digitemp = new Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']);
$rrdtemp = new \Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']); $rrdtemp = new Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']);
$num = $digitemp->getNumSensors(); $num = $digitemp->getNumSensors();
for ($i = 0; $i < $num; ++$i) { for ($i = 0; $i < $num; ++$i) {
$id = $digitemp->getSensorId($i); $id = $digitemp->getSensorId($i);