Code cleanup, no functional changes

This commit is contained in:
2023-06-27 19:39:11 +12:00
parent b70a36003a
commit ad36da0bb1
64 changed files with 466 additions and 438 deletions

View File

@@ -3,7 +3,6 @@
namespace App\Models;
use Carbon\Carbon;
use Exception;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -131,7 +130,7 @@ class Address extends Model
return $this->hasOne(self::class,NULL,'void');
default:
throw new Exception('Unknown role: '.serialize($this->role));
throw new \Exception('Unknown role: '.serialize($this->role));
}
} else {
@@ -219,7 +218,7 @@ class Address extends Model
* Who we send this systems mail to.
*
* @return Address|null
* @throws Exception
* @throws \Exception
*/
public function parent(): ?Address
{
@@ -287,7 +286,7 @@ class Address extends Model
return NULL;
default:
throw new Exception('Unknown role: '.serialize($this->role));
throw new \Exception('Unknown role: '.serialize($this->role));
}
return $parent?->parent();
@@ -370,7 +369,7 @@ class Address extends Model
* @param bool $create
* @param System|null $so
* @return Address|null
* @throws Exception
* @throws \Exception
*/
public static function findFTN(string $address,bool $create=FALSE,System $so=NULL): ?self
{
@@ -426,7 +425,7 @@ class Address extends Model
if ($create) {
if (! $so)
throw new Exception(sprintf('%s:AKA create requested for [%s], but system not provided',self::LOGKEY,$address));
throw new \Exception(sprintf('%s:AKA create requested for [%s], but system not provided',self::LOGKEY,$address));
if (! $ftn['d']) {
Log::alert(sprintf('%s:! Refusing to create address [%s] no domain available',self::LOGKEY,$address));
@@ -507,7 +506,7 @@ class Address extends Model
try {
Log::info(sprintf('%s:Checking Activation code [%s] is valid for user [%d]',self::LOGKEY,$code,$uo->id));
return ($code == $this->set_activation($uo));
return ($code === $this->set_activation($uo));
} catch (\Exception $e) {
Log::error(sprintf('%s:! Activation code [%s] invalid for user [%d]',self::LOGKEY,$code,$uo->id));
@@ -687,21 +686,21 @@ class Address extends Model
*
* @param string $ftn
* @return array
* @throws Exception
* @throws \Exception
*/
public static function parseFTN(string $ftn): array
{
if (! preg_match(sprintf('#^%s$#',self::ftn_regex),strtolower($ftn),$matches))
throw new Exception('Invalid FTN: '.$ftn);
throw new \Exception('Invalid FTN: '.$ftn);
// Check our numbers are correct.
foreach ([1,2,3] as $i) {
if ((! is_numeric($matches[$i])) || ($matches[$i] > DomainController::NUMBER_MAX))
throw new Exception('Invalid FTN: '.$ftn);
throw new \Exception('Invalid FTN: '.$ftn);
}
if (isset($matches[5]) AND ((! is_numeric($matches[$i])) || ($matches[5] > DomainController::NUMBER_MAX)))
throw new Exception('Invalid FTN: '.$ftn);
throw new \Exception('Invalid FTN: '.$ftn);
return [
'z'=>(int)$matches[1],

View File

@@ -213,7 +213,7 @@ final class Echomail extends Model implements Packet
if ($x=$this->path->firstWhere('pivot.parent_id',$start)) {
$result->push($x->$display);
$result->push($this->pathorder($display,$x->pivot->id));
};
}
return $result->flatten()->filter();
}

View File

@@ -64,7 +64,7 @@ class File extends Model
unlink(Storage::disk('local')->path($model->fullname));
} else {
throw new \Exception(sprintf('Unable to move file [%s] to [%s]',$model->fullname,$model->full_storage_path));
};
}
// Delete anything being replaced
// @todo implement replace

View File

@@ -172,7 +172,7 @@ final class Netmail extends Model implements Packet
if ($x=$this->path->firstWhere('pivot.parent_id',$start)) {
$result->push($x->$display);
$result->push($this->pathorder($display,$x->pivot->id));
};
}
return $result->flatten()->filter();
}