Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2019-08-20 18:39:57 +02:00
parent 8e23629dc0
commit 1629f31fed
31 changed files with 187 additions and 211 deletions

View file

@ -83,13 +83,13 @@ class Category extends PartsContainingDBElement
* @var string
* @ORM\Column(type="text")
*/
protected $partname_hint = "";
protected $partname_hint = '';
/**
* @var string
* @ORM\Column(type="text")
*/
protected $partname_regex = "";
protected $partname_regex = '';
/**
* @var bool
@ -119,13 +119,13 @@ class Category extends PartsContainingDBElement
* @var string
* @ORM\Column(type="text")
*/
protected $default_description = "";
protected $default_description = '';
/**
* @var string
* @ORM\Column(type="text")
*/
protected $default_comment = "";
protected $default_comment = '';
/**
* Returns the ID as an string, defined by the element class.

View file

@ -128,73 +128,14 @@ class Footprint extends PartsContainingDBElement
/**
* Get the filename of the 3d model (absolute path from filesystem root).
*
* @param bool $absolute If set to true, then the absolute filename (from system root) is returned.
* If set to false, then the path relative to Part-DB folder is returned.
*
* @return string * the absolute path to the model (from filesystem root), as a UNIX path (with slashes)
* * an empty string if there is no model
*/
public function get3dFilename(bool $absolute = true): string
public function get3dFilename(): string
{
if (true === $absolute) {
//TODO
throw new \Exception('Not Implemented yet...');
//return str_replace('%BASE%', BASE, $this->db_data['filename_3d']);
}
return $this->filename_3d;
}
/**
* Check if the filename of this footprint is valid (picture exists).
*
* This method is used to get all footprints with broken filename
* (Footprint::get_broken_filename_footprints()).
*
* An empty filename is a valid filename.
*
* @return bool * true if file exists or filename is empty
* * false if there is no file with this filename
*/
public function isFilenameValid(): bool
{
if (empty($this->getFilename())) {
return true;
}
return file_exists($this->getFilename());
}
/**
* Check if the filename of this 3d footprint is valid (model exists and have ).
*
* This method is used to get all footprints with broken 3d filename
* (Footprint::get_broken_3d_filename_footprints()).
*
* An empty filename is a valid filename.
*
* @return bool * true if file exists or filename is empty
* * false if there is no file with this filename
*/
public function is3dFilenameValid(): bool
{
if (empty($this->get3dFilename())) {
return true;
}
//Check if file is X3D-Model (these has .x3d extension)
if (false === strpos($this->get3dFilename(), '.x3d')) {
return false;
}
return file_exists($this->get3dFilename());
}
/*****************************************************************************
* Setters
****************************************************************************/
/********************************************************************************
*
* Setters
@ -203,25 +144,8 @@ class Footprint extends PartsContainingDBElement
/**
* Change the filename of this footprint.
*
* The filename won't be checked if it is valid.
* It's not really a Problem if there is no such file...
* (For this purpose we have the method Footprint::get_broken_filename_footprints())
*
* @param string $new_filename * the new filename (absolute path from filesystem root, as a UNIX path [only slashes!] !! )
* * see also lib.functions.php::to_unix_path()
*
* It's really important that you pass the whole (UNIX) path from filesystem root!
* If the file is located in the base directory of Part-DB, the base path
* will be automatically replaced with a placeholder before write it in the database.
* This way, the filenames are still correct if the installation directory
* of Part-DB is moved.
*
* The path-replacing will be done in Footprint::check_values_validity(), not here.
*
* @return Footprint
*
* @throws \Exception if there was an error
* @param string $new_filename The new file name
* @return Footprint
*/
public function setFilename(string $new_filename): self
{
@ -232,8 +156,9 @@ class Footprint extends PartsContainingDBElement
/**
* Change the 3d model filename of this footprint.
* @param string $new_filename The new filename
*
* @throws \Exception if there was an error
* @return Footprint
*/
public function set3dFilename(string $new_filename): self
{

View file

@ -33,7 +33,6 @@ namespace App\Entity\Parts;
use App\Entity\Base\PartsContainingDBElement;
use App\Entity\Base\StructuralDBElement;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
@ -127,7 +126,7 @@ class MeasurementUnit extends PartsContainingDBElement
*/
public function setIsInteger(bool $isInteger): MeasurementUnit
{
$this->isInteger = $isInteger;
$this->is_integer = $isInteger;
return $this;
}
@ -145,7 +144,7 @@ class MeasurementUnit extends PartsContainingDBElement
*/
public function setUseSIPrefix(bool $usesSIPrefixes): MeasurementUnit
{
$this->useSIPrefixes = $usesSIPrefixes;
$this->use_si_prefix = $usesSIPrefixes;
return $this;
}
}

View file

@ -71,7 +71,6 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -169,7 +168,7 @@ class Part extends AttachmentContainingDBElement
*
* @ColumnSecurity(prefix="name")
*/
protected $name = '';
protected $name;
/**
* @var string
@ -303,12 +302,18 @@ class Part extends AttachmentContainingDBElement
/**
* Get the count of parts which must be in stock at least.
* If a integer-based part unit is selected, the value will be rounded to integers
*
* @return int count of parts which must be in stock at least
* @return float count of parts which must be in stock at least
*/
public function getMinAmount(): float
{
return $this->minamount;
if ($this->useFloatAmount()) {
return $this->minamount;
}
return round($this->minamount);
}
/**
@ -476,7 +481,7 @@ class Part extends AttachmentContainingDBElement
*
* @param bool $hide_obsolete If true, obsolete orderdetails will NOT be returned
*
* @return Orderdetail[] * all orderdetails as a one-dimensional array of Orderdetails objects
* @return Collection|Orderdetail[] * all orderdetails as a one-dimensional array of Orderdetails objects
* (empty array if there are no ones)
* * the array is sorted by the suppliers names / minimum order quantity
*
@ -638,7 +643,7 @@ class Part extends AttachmentContainingDBElement
/**
* Gets the measurement unit in which the part's amount should be measured.
* Returns null if no specific unit was that. That means the parts are measured simply in quantity numbers.
* @return ?MeasurementUnit
* @return MeasurementUnit|null
*/
public function getPartUnit(): ?MeasurementUnit
{
@ -648,7 +653,7 @@ class Part extends AttachmentContainingDBElement
/**
* Sets the measurement unit in which the part's amount should be measured.
* Set to null, if the part should be measured in quantities.
* @param ?MeasurementUnit $partUnit
* @param MeasurementUnit|null $partUnit
* @return Part
*/
public function setPartUnit(?MeasurementUnit $partUnit): Part
@ -762,7 +767,7 @@ class Part extends AttachmentContainingDBElement
* Set the minimum amount of parts that have to be instock.
* See getPartUnit() for the associated unit.
*
* @param int $new_mininstock the new count of parts which should be in stock at least
* @param int $new_minamount the new count of parts which should be in stock at least
*
* @return self
*/

View file

@ -33,7 +33,6 @@ namespace App\Entity\Parts;
use App\Entity\Base\DBElement;
use App\Entity\Base\NamedDBElement;
use App\Entity\Base\TimestampTrait;
use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM;
@ -56,13 +55,13 @@ class PartLot extends DBElement
* @var string A short description about this lot, shown in table
* @ORM\Column(type="text")
*/
protected $description = "";
protected $description = '';
/**
* @var string A comment stored with this lot.
* @ORM\Column(type="text")
*/
protected $comment = "";
protected $comment = '';
/**
* @var ?\DateTime Set a time until when the lot must be used.
@ -126,7 +125,7 @@ class PartLot extends DBElement
*/
public function isExpired(): ?bool
{
if ($this->expiration_date == null) {
if ($this->expiration_date === null) {
return null;
}

View file

@ -61,9 +61,7 @@ declare(strict_types=1);
namespace App\Entity\Parts;
use App\Entity\Base\PartsContainingDBElement;
use App\Entity\Base\StructuralDBElement;
use App\Form\Type\StructuralEntityType;
use Doctrine\ORM\Mapping as ORM;
/**