Code cleanup, no functional changes
This commit is contained in:
@@ -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],
|
||||
|
Reference in New Issue
Block a user