Avoid passing null
to strlen & str_ireplace
This commit is contained in:
parent
b75b0432d0
commit
164287ec20
2 changed files with 26 additions and 17 deletions
|
@ -45,15 +45,24 @@ namespace ncc\Classes\NccExtension;
|
|||
if($input == null)
|
||||
return null;
|
||||
|
||||
$input = str_replace(AssemblyConstants::AssemblyName, $assembly->Name, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyPackage, $assembly->Package, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyDescription, $assembly->Description, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyCompany, $assembly->Company, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyProduct, $assembly->Product, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyCopyright, $assembly->Copyright, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyTrademark, $assembly->Trademark, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyVersion, $assembly->Version, $input);
|
||||
$input = str_replace(AssemblyConstants::AssemblyUid, $assembly->UUID, $input);
|
||||
if($assembly->Name !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyName, $assembly->Name, $input);
|
||||
if($assembly->Package !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyPackage, $assembly->Package, $input);
|
||||
if($assembly->Description !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyDescription, $assembly->Description, $input);
|
||||
if($assembly->Company !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyCompany, $assembly->Company, $input);
|
||||
if($assembly->Product !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyProduct, $assembly->Product, $input);
|
||||
if($assembly->Copyright !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyCopyright, $assembly->Copyright, $input);
|
||||
if($assembly->Trademark !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyTrademark, $assembly->Trademark, $input);
|
||||
if($assembly->Version !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyVersion, $assembly->Version, $input);
|
||||
if($assembly->UUID !== null)
|
||||
$input = str_replace(AssemblyConstants::AssemblyUid, $assembly->UUID, $input);
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!Validate::version($this->Version))
|
||||
if($this->Version !== null && !Validate::version($this->Version))
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The version number is invalid', 'Assembly.Version');
|
||||
|
@ -120,7 +120,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!preg_match(RegexPatterns::PackageNameFormat, $this->Package))
|
||||
if($this->Package !== null && !preg_match(RegexPatterns::PackageNameFormat, $this->Package))
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The package name is invalid', 'Assembly.Package');
|
||||
|
@ -128,7 +128,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(strlen($this->Name) > 126)
|
||||
if($this->Name !== null && strlen($this->Name) > 126)
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The name cannot be larger than 126 characters', 'Assembly.Name');
|
||||
|
@ -136,7 +136,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(strlen($this->Description) > 512)
|
||||
if($this->Description !== null && strlen($this->Description) > 512)
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The description cannot be larger than 512 characters', 'Assembly.Description');
|
||||
|
@ -144,7 +144,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(strlen($this->Company) > 126)
|
||||
if($this->Company !== null && strlen($this->Company) > 126)
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The company cannot be larger than 126 characters', 'Assembly.Company');
|
||||
|
@ -152,7 +152,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(strlen($this->Product) > 256)
|
||||
if($this->Product !== null && strlen($this->Product) > 256)
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The company cannot be larger than 256 characters', 'Assembly.Product');
|
||||
|
@ -160,7 +160,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(strlen($this->Copyright) > 256)
|
||||
if($this->Copyright !== null && strlen($this->Copyright) > 256)
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The copyright cannot be larger than 256 characters', 'Assembly.Copyright');
|
||||
|
@ -168,7 +168,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(strlen($this->Trademark) > 256)
|
||||
if($this->Trademark !== null && strlen($this->Trademark) > 256)
|
||||
{
|
||||
if($throw_exception)
|
||||
throw new InvalidProjectConfigurationException('The trademark cannot be larger than 256 characters', 'Assembly.Trademark');
|
||||
|
|
Loading…
Add table
Reference in a new issue