Added an PHP CS fixer config file and applied it to files.

We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
Jan Böhmer 2019-11-09 00:47:20 +01:00
parent 89258bc102
commit e557bdedd5
210 changed files with 2099 additions and 2742 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
declare(strict_types=1);
@ -56,7 +55,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Category extends PartsContainingDBElement
{
/**
* @var Collection|CategoryAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
@ -147,12 +145,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param string $partname_hint
* @return Category
*/
public function setPartnameHint(string $partname_hint): Category
public function setPartnameHint(string $partname_hint): self
{
$this->partname_hint = $partname_hint;
return $this;
}
@ -165,12 +163,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param string $partname_regex
* @return Category
*/
public function setPartnameRegex(string $partname_regex): Category
public function setPartnameRegex(string $partname_regex): self
{
$this->partname_regex = $partname_regex;
return $this;
}
@ -183,12 +181,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param bool $disable_footprints
* @return Category
*/
public function setDisableFootprints(bool $disable_footprints): Category
public function setDisableFootprints(bool $disable_footprints): self
{
$this->disable_footprints = $disable_footprints;
return $this;
}
@ -201,12 +199,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param bool $disable_manufacturers
* @return Category
*/
public function setDisableManufacturers(bool $disable_manufacturers): Category
public function setDisableManufacturers(bool $disable_manufacturers): self
{
$this->disable_manufacturers = $disable_manufacturers;
return $this;
}
@ -219,12 +217,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param bool $disable_autodatasheets
* @return Category
*/
public function setDisableAutodatasheets(bool $disable_autodatasheets): Category
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
{
$this->disable_autodatasheets = $disable_autodatasheets;
return $this;
}
@ -237,12 +235,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param bool $disable_properties
* @return Category
*/
public function setDisableProperties(bool $disable_properties): Category
public function setDisableProperties(bool $disable_properties): self
{
$this->disable_properties = $disable_properties;
return $this;
}
@ -255,12 +253,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param string $default_description
* @return Category
*/
public function setDefaultDescription(string $default_description): Category
public function setDefaultDescription(string $default_description): self
{
$this->default_description = $default_description;
return $this;
}
@ -273,14 +271,12 @@ class Category extends PartsContainingDBElement
}
/**
* @param string $default_comment
* @return Category
*/
public function setDefaultComment(string $default_comment): Category
public function setDefaultComment(string $default_comment): self
{
$this->default_comment = $default_comment;
return $this;
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
declare(strict_types=1);
@ -52,7 +51,6 @@ declare(strict_types=1);
namespace App\Entity\Parts;
use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\FootprintAttachment;
use App\Entity\Base\PartsContainingDBElement;
use Doctrine\Common\Collections\Collection;
@ -112,9 +110,10 @@ class Footprint extends PartsContainingDBElement
/**
* Returns the 3D Model associated with this footprint.
*
* @return FootprintAttachment|null
*/
public function getFootprint3d() : ?FootprintAttachment
public function getFootprint3d(): ?FootprintAttachment
{
return $this->footprint_3d;
}
@ -127,13 +126,13 @@ class Footprint extends PartsContainingDBElement
/**
* Sets the 3D Model associated with this footprint.
* @param FootprintAttachment|null $new_attachment
*
* @return Footprint
*/
public function setFootprint3d(?FootprintAttachment $new_attachment) : Footprint
public function setFootprint3d(?FootprintAttachment $new_attachment): self
{
$this->footprint_3d = $new_attachment;
return $this;
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
declare(strict_types=1);
@ -52,7 +51,6 @@ declare(strict_types=1);
namespace App\Entity\Parts;
use App\Entity\Attachments\FootprintAttachment;
use App\Entity\Attachments\ManufacturerAttachment;
use App\Entity\Base\Company;
use Doctrine\Common\Collections\Collection;
@ -72,7 +70,6 @@ class Manufacturer extends Company
*/
protected $attachments;
/**
* @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent")
*/

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,13 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts;
use App\Entity\Attachments\ManufacturerAttachment;
use App\Entity\Attachments\MeasurementUnitAttachment;
use App\Entity\Base\PartsContainingDBElement;
use Doctrine\Common\Collections\Collection;
@ -35,14 +32,12 @@ use Symfony\Component\Validator\Constraints as Assert;
* This unit represents the unit in which the amount of parts in stock are measured.
* This could be something like N, gramms, meters, etc...
*
* @package App\Entity
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table(name="`measurement_units`")
* @UniqueEntity("unit")
*/
class MeasurementUnit extends PartsContainingDBElement
{
/**
* @var Collection|MeasurementUnitAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
@ -51,7 +46,7 @@ class MeasurementUnit extends PartsContainingDBElement
/**
* @var string The unit symbol that should be used for the Unit. This could be something like "", g (for gramms)
* or m (for meters).
* or m (for meters).
* @ORM\Column(type="string", name="unit", nullable=true)
* @Assert\Length(max=10)
*/
@ -59,14 +54,14 @@ class MeasurementUnit extends PartsContainingDBElement
/**
* @var bool Determines if the amount value associated with this unit should be treated as integer.
* Set to false, to measure continuous sizes likes masses or lengthes.
* Set to false, to measure continuous sizes likes masses or lengthes.
* @ORM\Column(type="boolean", name="is_integer")
*/
protected $is_integer = false;
/**
* @var bool Determines if the unit can be used with SI Prefixes (kilo, giga, milli, etc.).
* Useful for sizes like meters.
* Useful for sizes like meters.
* @ORM\Column(type="boolean", name="use_si_prefix")
*/
protected $use_si_prefix = false;
@ -92,11 +87,10 @@ class MeasurementUnit extends PartsContainingDBElement
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*
*/
public function getIDString(): string
{
return 'MU' . $this->getID();
return 'MU'.$this->getID();
}
/**
@ -109,11 +103,13 @@ class MeasurementUnit extends PartsContainingDBElement
/**
* @param string $unit
*
* @return MeasurementUnit
*/
public function setUnit(?string $unit): MeasurementUnit
public function setUnit(?string $unit): self
{
$this->unit = $unit;
return $this;
}
@ -126,12 +122,12 @@ class MeasurementUnit extends PartsContainingDBElement
}
/**
* @param bool $isInteger
* @return MeasurementUnit
*/
public function setIsInteger(bool $isInteger): MeasurementUnit
public function setIsInteger(bool $isInteger): self
{
$this->is_integer = $isInteger;
return $this;
}
@ -144,12 +140,12 @@ class MeasurementUnit extends PartsContainingDBElement
}
/**
* @param bool $usesSIPrefixes
* @return MeasurementUnit
*/
public function setUseSIPrefix(bool $usesSIPrefixes): MeasurementUnit
public function setUseSIPrefix(bool $usesSIPrefixes): self
{
$this->use_si_prefix = $usesSIPrefixes;
return $this;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
declare(strict_types=1);
@ -54,9 +53,9 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\AttachmentContainingDBElement;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\Devices\Device;
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\Parts\PartTraits\BasicPropertyTrait;
use App\Entity\Parts\PartTraits\InstockTrait;
use App\Entity\Parts\PartTraits\ManufacturerTrait;
@ -64,7 +63,6 @@ use App\Entity\Parts\PartTraits\OrderTrait;
use App\Security\Annotations\ColumnSecurity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -143,7 +141,7 @@ class Part extends AttachmentContainingDBElement
*/
public function getIDString(): string
{
return 'P' . sprintf('%06d', $this->getID());
return 'P'.sprintf('%06d', $this->getID());
}
/**
@ -152,11 +150,9 @@ class Part extends AttachmentContainingDBElement
* @return Device[] * all devices which uses this part as a one-dimensional array of Device objects
* (empty array if there are no ones)
* * the array is sorted by the devices names
*
*/
public function getDevices(): array
{
return $this->devices;
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,12 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts;
use App\Entity\Base\DBElement;
use App\Entity\Base\TimestampTrait;
use App\Entity\Parts\PartTraits\InstockTrait;
@ -34,7 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* This entity describes a lot where parts can be stored.
* It is the connection between a part and its store locations.
* @package App\Entity\Parts
*
* @ORM\Entity()
* @ORM\Table(name="part_lots")
* @ORM\HasLifecycleCallbacks()
@ -42,7 +40,6 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
class PartLot extends DBElement
{
use TimestampTrait;
/**
@ -59,7 +56,7 @@ class PartLot extends DBElement
/**
* @var ?\DateTime Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitley.
* Set to null, if the lot can be used indefinitley.
* @ORM\Column(type="datetime", name="expiration_date", nullable=true)
*/
protected $expiration_date;
@ -86,7 +83,6 @@ class PartLot extends DBElement
*/
protected $instock_unknown = false;
/**
* @var float For continuos sizes (length, volume, etc.) the instock is saved here.
* @ORM\Column(type="float")
@ -95,7 +91,7 @@ class PartLot extends DBElement
protected $amount = 0;
/**
* @var boolean Determines if this lot was manually marked for refilling.
* @var bool Determines if this lot was manually marked for refilling.
* @ORM\Column(type="boolean")
*/
protected $needs_refill = false;
@ -105,21 +101,21 @@ class PartLot extends DBElement
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*
*/
public function getIDString(): string
{
return 'PL' . $this->getID();
return 'PL'.$this->getID();
}
/**
* Check if the current part lot is expired.
* This is the case, if the expiration date is greater the the current date.
*
* @return bool|null True, if the part lot is expired. Returns null, if no expiration date was set.
*/
public function isExpired(): ?bool
{
if ($this->expiration_date === null) {
if (null === $this->expiration_date) {
return null;
}
@ -129,6 +125,7 @@ class PartLot extends DBElement
/**
* Gets the description of the part lot. Similar to a "name" of the part lot.
*
* @return string
*/
public function getDescription(): string
@ -138,17 +135,19 @@ class PartLot extends DBElement
/**
* Sets the description of the part lot.
* @param string $description
*
* @return PartLot
*/
public function setDescription(string $description): PartLot
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
/**
* Gets the comment for this part lot.
*
* @return string
*/
public function getComment(): string
@ -158,17 +157,19 @@ class PartLot extends DBElement
/**
* Sets the comment for this part lot.
* @param string $comment
*
* @return PartLot
*/
public function setComment(string $comment): PartLot
public function setComment(string $comment): self
{
$this->comment = $comment;
return $this;
}
/**
* Gets the expiration date for the part lot. Returns null, if no expiration date was set.
*
* @return \DateTime|null
*/
public function getExpirationDate(): ?\DateTime
@ -178,17 +179,21 @@ class PartLot extends DBElement
/**
* Sets the expiration date for the part lot. Set to null, if the part lot does not expires.
*
* @param \DateTime $expiration_date
*
* @return PartLot
*/
public function setExpirationDate(?\DateTime $expiration_date): PartLot
public function setExpirationDate(?\DateTime $expiration_date): self
{
$this->expiration_date = $expiration_date;
return $this;
}
/**
* Gets the storage locatiion, where this part lot is stored.
*
* @return Storelocation|null The store location where this part is stored
*/
public function getStorageLocation(): ?Storelocation
@ -197,18 +202,20 @@ class PartLot extends DBElement
}
/**
* Sets the storage location, where this part lot is stored
* @param Storelocation|null $storage_location
* Sets the storage location, where this part lot is stored.
*
* @return PartLot
*/
public function setStorageLocation(?Storelocation $storage_location): PartLot
public function setStorageLocation(?Storelocation $storage_location): self
{
$this->storage_location = $storage_location;
return $this;
}
/**
* Return the part that is stored in this part lot.
*
* @return Part
*/
public function getPart(): Part
@ -218,12 +225,15 @@ class PartLot extends DBElement
/**
* Sets the part that is stored in this part lot.
*
* @param Part|InstockTrait $part
*
* @return PartLot
*/
public function setPart(Part $part): PartLot
public function setPart(Part $part): self
{
$this->part = $part;
return $this;
}
@ -239,12 +249,13 @@ class PartLot extends DBElement
/**
* Set the unknown instock status of this part lot.
* @param bool $instock_unknown
*
* @return PartLot
*/
public function setInstockUnknown(bool $instock_unknown): PartLot
public function setInstockUnknown(bool $instock_unknown): self
{
$this->instock_unknown = $instock_unknown;
return $this;
}
@ -256,17 +267,17 @@ class PartLot extends DBElement
if ($this->part instanceof Part && !$this->part->useFloatAmount()) {
return round($this->amount);
}
return (float) $this->amount;
}
public function setAmount(float $new_amount): PartLot
public function setAmount(float $new_amount): self
{
$this->amount = $new_amount;
$this->amount = $new_amount;
return $this;
}
/**
* @return bool
*/
@ -276,14 +287,12 @@ class PartLot extends DBElement
}
/**
* @param bool $needs_refill
* @return PartLot
*/
public function setNeedsRefill(bool $needs_refill): PartLot
public function setNeedsRefill(bool $needs_refill): self
{
$this->needs_refill = $needs_refill;
return $this;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,18 +17,15 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Part;
use App\Security\Annotations\ColumnSecurity;
/**
* Advanced properties of a part, not related to a more specific group.
* @package App\Entity\Parts\PartTraits
*/
trait AdvancedPropertyTrait
{
@ -56,6 +53,7 @@ trait AdvancedPropertyTrait
/**
* Checks if this part is marked, for that it needs further review.
*
* @return bool
*/
public function isNeedsReview(): bool
@ -65,18 +63,19 @@ trait AdvancedPropertyTrait
/**
* Sets the "needs review" status of this part.
* @param bool $needs_review
*
* @return Part|self
*/
public function setNeedsReview(bool $needs_review): self
{
$this->needs_review = $needs_review;
return $this;
}
/**
* Gets a comma separated list, of tags, that are assigned to this part
* Gets a comma separated list, of tags, that are assigned to this part.
*
* @return string
*/
public function getTags(): string
@ -86,18 +85,20 @@ trait AdvancedPropertyTrait
/**
* Sets a comma separated list of tags, that are assigned to this part.
* @param string $tags
*
* @return self
*/
public function setTags(string $tags): self
{
$this->tags = $tags;
return $this;
}
/**
* Returns the mass of a single part unit.
* Returns null, if the mass is unknown/not set yet
* Returns null, if the mass is unknown/not set yet.
*
* @return float|null
*/
public function getMass(): ?float
@ -108,14 +109,13 @@ trait AdvancedPropertyTrait
/**
* Sets the mass of a single part unit.
* Sett to null, if the mass is unknown.
* @param float|null $mass
*
* @return self
*/
public function setMass(?float $mass): self
{
$this->mass = $mass;
return $this;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,12 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Part;
@ -60,7 +58,7 @@ trait BasicPropertyTrait
/**
* @var Category The category this part belongs too (e.g. Resistors). Use tags, for more complex grouping.
* Every part must have a category.
* Every part must have a category.
* @ORM\ManyToOne(targetEntity="Category", inversedBy="parts")
* @ORM\JoinColumn(name="id_category", referencedColumnName="id", nullable=false)
* @ColumnSecurity(prefix="category", type="App\Entity\Parts\Category")
@ -80,6 +78,7 @@ trait BasicPropertyTrait
/**
* Get the description string like it is saved in the database.
* This can contain BBCode, it is not parsed yet.
*
* @return string the description
*/
public function getDescription(): string
@ -89,6 +88,7 @@ trait BasicPropertyTrait
/**
* Get the comment associated with this part.
*
* @return string The raw/unparsed comment
*/
public function getComment(): string
@ -99,6 +99,7 @@ trait BasicPropertyTrait
/**
* Get if this part is visible.
* This property is not used yet.
*
* @return bool true if this part is visible
* false if this part isn't visible
*/
@ -109,6 +110,7 @@ trait BasicPropertyTrait
/**
* Check if this part is a favorite.
*
* @return bool * true if this part is a favorite
* * false if this part is not a favorite.
*/
@ -117,10 +119,10 @@ trait BasicPropertyTrait
return $this->favorite;
}
/**
* Get the category of this part (e.g. Resistors).
* There is always a category, for each part!
*
* @return Category the category of this part
*/
public function getCategory(): ?Category
@ -129,7 +131,8 @@ trait BasicPropertyTrait
}
/**
* Gets the Footprint of this part (e.g. DIP8)
* Gets the Footprint of this part (e.g. DIP8).
*
* @return Footprint|null The footprint of this part. Null if this part should no have a footprint.
*/
public function getFootprint(): ?Footprint
@ -139,36 +142,44 @@ trait BasicPropertyTrait
/**
* Sets the description of this part.
*
* @param string $new_description the new description
*
* @return self
*/
public function setDescription(?string $new_description): self
{
$this->description = $new_description;
return $this;
}
/**
* Sets the comment property of this part.
*
* @param string $new_comment the new comment
*
* @return self
*/
public function setComment(string $new_comment): self
{
$this->comment = $new_comment;
return $this;
}
/**
* Set the category of this Part.
* The category property is required for every part, so you can not pass null like the other properties (footprints)
* The category property is required for every part, so you can not pass null like the other properties (footprints).
*
* @param Category $category The new category of this part
*
* @return self
*/
public function setCategory(Category $category): self
{
$this->category = $category;
return $this;
}
@ -183,6 +194,7 @@ trait BasicPropertyTrait
public function setFootprint(?Footprint $new_footprint): self
{
$this->footprint = $new_footprint;
return $this;
}
@ -197,7 +209,7 @@ trait BasicPropertyTrait
public function setFavorite(bool $new_favorite_status): self
{
$this->favorite = $new_favorite_status;
return $this;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,12 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\PartLot;
use App\Security\Annotations\ColumnSecurity;
@ -30,7 +28,6 @@ use Doctrine\Common\Collections\Collection;
/**
* This trait collects all aspects of a part related to instock, part lots.
* @package App\Entity\Parts\PartTraits
*/
trait InstockTrait
{
@ -44,7 +41,7 @@ trait InstockTrait
/**
* @var float The minimum amount of the part that has to be instock, otherwise more is ordered.
* Given in the partUnit.
* Given in the partUnit.
* @ORM\Column(type="float")
* @Assert\PositiveOrZero()
* @ColumnSecurity(prefix="mininstock", type="integer")
@ -61,9 +58,10 @@ trait InstockTrait
/**
* Get all part lots where this part is stored.
*
* @return PartLot[]|Collection
*/
public function getPartLots() : Collection
public function getPartLots(): Collection
{
return $this->partLots;
}
@ -71,30 +69,35 @@ trait InstockTrait
/**
* Adds the given part lot, to the list of part lots.
* The part lot is assigned to this part.
* @param PartLot $lot
*
* @return self
*/
public function addPartLot(PartLot $lot): self
{
$lot->setPart($this);
$this->partLots->add($lot);
return $this;
}
/**
* Removes the given part lot from the list of part lots.
*
* @param PartLot $lot The part lot that should be deleted.
*
* @return self
*/
public function removePartLot(PartLot $lot): self
{
$this->partLots->removeElement($lot);
return $this;
}
/**
* 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|null
*/
public function getPartUnit(): ?MeasurementUnit
@ -105,18 +108,19 @@ trait InstockTrait
/**
* 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|null $partUnit
*
* @return self
*/
public function setPartUnit(?MeasurementUnit $partUnit): self
{
$this->partUnit = $partUnit;
return $this;
}
/**
* 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
* If a integer-based part unit is selected, the value will be rounded to integers.
*
* @return float count of parts which must be in stock at least
*/
@ -132,6 +136,7 @@ trait InstockTrait
/**
* Checks if this part uses the float amount .
* This setting is based on the part unit (see MeasurementUnit->isInteger()).
*
* @return bool True if the float amount field should be used. False if the integer instock field should be used.
*/
public function useFloatAmount(): bool
@ -146,10 +151,11 @@ trait InstockTrait
/**
* Returns the summed amount of this part (over all part lots)
* Part Lots that have unknown value or are expired, are not used for this value
* Part Lots that have unknown value or are expired, are not used for this value.
*
* @return float The amount of parts given in partUnit
*/
public function getAmountSum() : float
public function getAmountSum(): float
{
//TODO: Find a method to do this natively in SQL, the current method could be a bit slow
$sum = 0;
@ -172,12 +178,15 @@ trait InstockTrait
/**
* Set the minimum amount of parts that have to be instock.
* See getPartUnit() for the associated unit.
*
* @param float $new_minamount the new count of parts which should be in stock at least
*
* @return self
*/
public function setMinAmount(float $new_minamount): self
{
$this->minamount = $new_minamount;
return $this;
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,12 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\Part;
use App\Security\Annotations\ColumnSecurity;
@ -30,7 +28,6 @@ use App\Validator\Constraints\Selectable;
/**
* In this trait all manufacturer related properties of a part are collected (like MPN, manufacturer URL).
* @package App\Entity\Parts\PartTraits
*/
trait ManufacturerTrait
{
@ -70,6 +67,7 @@ trait ManufacturerTrait
* Get the link to the website of the article on the manufacturers website
* When no this part has no explicit url set, then it is tried to generate one from the Manufacturer of this part
* automatically.
*
* @return string the link to the article
*/
public function getManufacturerProductUrl(): string
@ -87,6 +85,7 @@ trait ManufacturerTrait
/**
* Similar to getManufacturerProductUrl, but here only the database value is returned.
*
* @return string The manufacturer url saved in DB for this part.
*/
public function getCustomProductURL(): string
@ -103,7 +102,8 @@ trait ManufacturerTrait
* * "active": Part is in production and will be for the forseeable future
* * "nrfnd": Not recommended for new designs.
* * "eol": Part will become discontinued soon
* * "discontinued": Part is obsolete/discontinued by the manufacturer
* * "discontinued": Part is obsolete/discontinued by the manufacturer.
*
* @return string
*/
public function getManufacturingStatus(): ?string
@ -114,12 +114,13 @@ trait ManufacturerTrait
/**
* Sets the manufacturing status for this part
* See getManufacturingStatus() for valid values.
* @param string $manufacturing_status
*
* @return Part
*/
public function setManufacturingStatus(string $manufacturing_status): self
{
$this->manufacturing_status = $manufacturing_status;
return $this;
}
@ -133,9 +134,9 @@ trait ManufacturerTrait
return $this->manufacturer;
}
/**
* Returns the assigned manufacturer product number (MPN) for this part.
*
* @return string
*/
public function getManufacturerProductNumber(): string
@ -145,19 +146,22 @@ trait ManufacturerTrait
/**
* Sets the manufacturer product number (MPN) for this part.
* @param string $manufacturer_product_number
*
* @return Part
*/
public function setManufacturerProductNumber(string $manufacturer_product_number): self
{
$this->manufacturer_product_number = $manufacturer_product_number;
return $this;
}
/**
* Sets the URL to the manufacturer site about this Part.
* Set to "" if this part should use the automatically URL based on its manufacturer.
*
* @param string $new_url The new url
*
* @return self
*/
public function setManufacturerProductURL(string $new_url): self
@ -181,5 +185,4 @@ trait ManufacturerTrait
return $this;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,12 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Part;
use App\Entity\PriceInformations\Orderdetail;
use App\Security\Annotations\ColumnSecurity;
@ -30,7 +28,6 @@ use Doctrine\Common\Collections\Collection;
/**
* This trait collects all aspects of a part related to orders and priceinformations.
* @package App\Entity\Parts\PartTraits
*/
trait OrderTrait
{
@ -67,6 +64,7 @@ trait OrderTrait
/**
* Get the selected order orderdetails of this part.
*
* @return Orderdetail the selected order orderdetails
*/
public function getOrderOrderdetails(): ?Orderdetail
@ -76,6 +74,7 @@ trait OrderTrait
/**
* Get the order quantity of this part.
*
* @return int the order quantity
*/
public function getOrderQuantity(): int
@ -99,11 +98,10 @@ trait OrderTrait
* @param bool $hide_obsolete If true, obsolete orderdetails will NOT be returned
*
* @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
*
* (empty array if there are no ones)
* * the array is sorted by the suppliers names / minimum order quantity
*/
public function getOrderdetails(bool $hide_obsolete = false) : Collection
public function getOrderdetails(bool $hide_obsolete = false): Collection
{
//If needed hide the obsolete entries
if ($hide_obsolete) {
@ -123,38 +121,42 @@ trait OrderTrait
/**
* Adds the given orderdetail to list of orderdetails.
* The orderdetail is assigned to this part.
*
* @param Orderdetail $orderdetail The orderdetail that should be added.
*
* @return self
*/
public function addOrderdetail(Orderdetail $orderdetail) : self
public function addOrderdetail(Orderdetail $orderdetail): self
{
$orderdetail->setPart($this);
$this->orderdetails->add($orderdetail);
return $this;
}
/**
* Removes the given orderdetail from the list of orderdetails.
* @param Orderdetail $orderdetail
*
* @return OrderTrait
*/
public function removeOrderdetail(Orderdetail $orderdetail) : self
public function removeOrderdetail(Orderdetail $orderdetail): self
{
$this->orderdetails->removeElement($orderdetail);
return $this;
}
/**
* Set the "manual_order" attribute.
*
* @param bool $new_manual_order the new "manual_order" attribute
* @param int $new_order_quantity the new order quantity
* @param bool $new_manual_order the new "manual_order" attribute
* @param int $new_order_quantity the new order quantity
* @param Orderdetail|null $new_order_orderdetail * the ID of the new order orderdetails
* * or Zero for "no order orderdetails"
* * or NULL for automatic order orderdetails
* (if the part has exactly one orderdetails,
* set this orderdetails as order orderdetails.
* Otherwise, set "no order orderdetails")
* * or Zero for "no order orderdetails"
* * or NULL for automatic order orderdetails
* (if the part has exactly one orderdetails,
* set this orderdetails as order orderdetails.
* Otherwise, set "no order orderdetails")
*
* @return self
*/
@ -183,7 +185,7 @@ trait OrderTrait
{
$all_orderdetails = $this->getOrderdetails();
if (0 === count($all_orderdetails)) {
if (0 === \count($all_orderdetails)) {
return false;
}
@ -195,5 +197,4 @@ trait OrderTrait
return true;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
declare(strict_types=1);
@ -52,7 +51,6 @@ declare(strict_types=1);
namespace App\Entity\Parts;
use App\Entity\Attachments\ManufacturerAttachment;
use App\Entity\Attachments\StorelocationAttachment;
use App\Entity\Base\PartsContainingDBElement;
use Doctrine\Common\Collections\Collection;
@ -66,7 +64,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Storelocation extends PartsContainingDBElement
{
/**
* @var Collection|StorelocationAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
@ -148,12 +145,12 @@ class Storelocation extends PartsContainingDBElement
}
/**
* @param bool $only_single_part
* @return Storelocation
*/
public function setOnlySinglePart(bool $only_single_part): Storelocation
public function setOnlySinglePart(bool $only_single_part): self
{
$this->only_single_part = $only_single_part;
return $this;
}
@ -168,12 +165,12 @@ class Storelocation extends PartsContainingDBElement
}
/**
* @param bool $limit_to_existing_parts
* @return Storelocation
*/
public function setLimitToExistingParts(bool $limit_to_existing_parts): Storelocation
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
{
$this->limit_to_existing_parts = $limit_to_existing_parts;
return $this;
}
@ -186,17 +183,15 @@ class Storelocation extends PartsContainingDBElement
}
/**
* @param MeasurementUnit|null $storage_type
* @return Storelocation
*/
public function setStorageType(?MeasurementUnit $storage_type): Storelocation
public function setStorageType(?MeasurementUnit $storage_type): self
{
$this->storage_type = $storage_type;
return $this;
}
/********************************************************************************
*
* Setters
@ -211,9 +206,10 @@ class Storelocation extends PartsContainingDBElement
*
* @param bool $new_is_full * true means that the storelocation is full
* * false means that the storelocation isn't full
*
* @return Storelocation
*/
public function setIsFull(bool $new_is_full): Storelocation
public function setIsFull(bool $new_is_full): self
{
$this->is_full = $new_is_full;

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
declare(strict_types=1);
@ -52,7 +51,6 @@ declare(strict_types=1);
namespace App\Entity\Parts;
use App\Entity\Attachments\ManufacturerAttachment;
use App\Entity\Attachments\SupplierAttachment;
use App\Entity\Base\Company;
use App\Entity\PriceInformations\Currency;
@ -93,7 +91,7 @@ class Supplier extends Company
/**
* @var Currency|null The currency that should be used by default for order informations with this supplier.
* Set to null, to use global base currency.
* Set to null, to use global base currency.
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency")
* @ORM\JoinColumn(name="default_currency_id", referencedColumnName="id", nullable=true)
* @Selectable()
@ -101,7 +99,7 @@ class Supplier extends Company
protected $default_currency;
/**
* @var float|null The shipping costs that have to be paid, when ordering via this supplier.
* @var float|null the shipping costs that have to be paid, when ordering via this supplier
* @ORM\Column(name="shipping_costs", nullable=true, type="decimal", precision=11, scale=5)
* @Assert\PositiveOrZero()
*/
@ -118,45 +116,48 @@ class Supplier extends Company
/**
* Gets the currency that should be used by default, when creating a orderdetail with this supplier.
*
* @return ?Currency
*/
public function getDefaultCurrency() : ?Currency
public function getDefaultCurrency(): ?Currency
{
return $this->default_currency;
}
/**
* Sets the default currency.
*
* @param ?Currency $default_currency
* @return Supplier
*/
public function setDefaultCurrency(?Currency $default_currency) : Supplier
public function setDefaultCurrency(?Currency $default_currency): self
{
$this->default_currency = $default_currency;
return $this;
}
/**
* Gets the shipping costs for an order with this supplier, given in base currency.
*
* @return string|null A bcmath string with the shipping costs
*/
public function getShippingCosts() : ?string
public function getShippingCosts(): ?string
{
return $this->shipping_costs;
}
/**
* Sets the shipping costs for an order with this supplier.
* @param string|null $shipping_costs A bcmath string with the shipping costs.
* @return Supplier
*
* @param string|null $shipping_costs a bcmath string with the shipping costs
*/
public function setShippingCosts(?string $shipping_costs) : Supplier
public function setShippingCosts(?string $shipping_costs): self
{
$this->shipping_costs = $shipping_costs;
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.