Add types to entities

This commit is contained in:
Timothy Warren 2022-02-17 14:00:50 -05:00
parent 4ac9c728de
commit cebc5bd7b4
10 changed files with 91 additions and 88 deletions

View File

@ -2,6 +2,8 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Trait CameraTrait
*
@ -21,70 +23,70 @@ trait CameraTrait
* @ORM\JoinColumn(name="type_id", referencedColumnName="id")
* })
*/
private $type;
private ?CameraType $type;
/**
* @var string
*
* @ORM\Column(name="brand", type="string", length=64, nullable=false)
*/
private $brand;
private string $brand;
/**
* @var string
*
* @ORM\Column(name="mount", type="string", length=32, nullable=false)
*/
private $mount;
private string $mount;
/**
* @var string
*
* @ORM\Column(name="model", type="string", length=255, nullable=false)
*/
private $model;
private string $model;
/**
* @var boolean
*
* @ORM\Column(name="is_digital", type="boolean", nullable=false)
*/
private $isDigital;
private bool $isDigital;
/**
* @var string
*
* @ORM\Column(name="crop_factor", type="decimal", precision=10, scale=0, nullable=false)
*/
private $cropFactor = '1.0';
private string $cropFactor = '1.0';
/**
* @var boolean
*
* @ORM\Column(name="is_working", type="boolean", nullable=false)
*/
private $isWorking;
private bool $isWorking;
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private $notes;
private ?string $notes;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", length=20, nullable=false)
*/
private $serial;
private string $serial;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false)
*/
private $formerlyOwned = false;
private bool $formerlyOwned = FALSE;
/**
* @var string
@ -98,21 +100,21 @@ trait CameraTrait
*
* @ORM\Column(name="battery_type", type="string", nullable=true)
*/
private $batteryType;
private ?string $batteryType;
/**
* @var string
*
* @ORM\Column(name="film_format", type="string", nullable=true)
*/
private $filmFormat = '135';
private ?string $filmFormat = '135';
/**
* @var boolean
*
* @ORM\Column(name="received", type="boolean", nullable=true)
*/
private $received = false;
private ?bool $received = FALSE;
/**
* Get id
@ -155,7 +157,7 @@ trait CameraTrait
*
* @return self
*/
public function setBrand($brand): self
public function setBrand(string $brand): self
{
$this->brand = $brand;
@ -179,7 +181,7 @@ trait CameraTrait
*
* @return self
*/
public function setMount($mount): self
public function setMount(string $mount): self
{
$this->mount = $mount;
@ -203,7 +205,7 @@ trait CameraTrait
*
* @return self
*/
public function setModel($model): self
public function setModel(string $model): self
{
$this->model = $model;
@ -227,7 +229,7 @@ trait CameraTrait
*
* @return self
*/
public function setIsDigital($isDigital): self
public function setIsDigital(bool $isDigital): self
{
$this->isDigital = $isDigital;
@ -251,7 +253,7 @@ trait CameraTrait
*
* @return self
*/
public function setCropFactor($cropFactor): self
public function setCropFactor(string $cropFactor): self
{
$this->cropFactor = $cropFactor;
@ -275,7 +277,7 @@ trait CameraTrait
*
* @return self
*/
public function setIsWorking($isWorking): self
public function setIsWorking(bool $isWorking): self
{
$this->isWorking = $isWorking;
@ -435,5 +437,4 @@ trait CameraTrait
{
return $this->received;
}
}

View File

@ -27,14 +27,14 @@ class CameraType
*
* @ORM\Column(name="type", type="string", length=255, nullable=false)
*/
private $type;
private string $type;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
private ?string $description;
/**

View File

@ -26,91 +26,91 @@ class Film {
*
* @ORM\Column(name="brand", type="string", nullable=false)
*/
private $brand;
private string $brand;
/**
* @var string
*
* @ORM\Column(name="product_line", type="string", nullable=true)
*/
private $productLine;
private ?string $productLine;
/**
* @var string
*
* @ORM\Column(name="film_name", type="string", nullable=false)
*/
private $filmName;
private string $filmName;
/**
* @var string
*
* @ORM\Column(name="film_alias", type="string", nullable=true)
*/
private $filmAlias;
private ?string $filmAlias;
/**
* @var int
*
* @ORM\Column(name="film_speed_asa", type="integer", nullable=false)
*/
private $filmSpeedAsa;
private int $filmSpeedAsa;
/**
* @var int
*
* @ORM\Column(name="film_speed_din", type="integer", nullable=false)
*/
private $filmSpeedDin;
private int $filmSpeedDin;
/**
* @var string
*
* @ORM\Column(name="film_format", type="string", nullable=false)
*/
private $filmFormat;
private string $filmFormat;
/**
* @var string
*
* @ORM\Column(name="film_base", type="string", nullable=false, options={"default"="Cellulose Triacetate"})
*/
private $filmBase = 'Cellulose Triacetate';
private string $filmBase = 'Cellulose Triacetate';
/**
* @var int
*
* @ORM\Column(name="unused_rolls", type="integer", nullable=false, options={"default"=0})
*/
private $unusedRolls = 0;
private int $unusedRolls = 0;
/**
* @var int
*
* @ORM\Column(name="rolls_in_camera", type="integer", nullable=false, options={"default"=0})
*/
private $rollsInCamera = 0;
private int $rollsInCamera = 0;
/**
* @var int
*
* @ORM\Column(name="developed_rolls", type="integer", nullable=false, options={"default"=0})
*/
private $developedRolls = 0;
private int $developedRolls = 0;
/**
* @var string
*
* @ORM\Column(name="chemistry", type="string", nullable=false, options={"default"="C-41"})
*/
private $chemistry = 'C-41';
private string $chemistry = 'C-41';
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private $notes;
private ?string $notes;
/**
* @return int

View File

@ -15,21 +15,21 @@ class FilmFormat
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
private int $id;
/**
* @var int
*
* @ORM\Column(name="number_id", type="integer")
*/
private $numberId;
private int $numberId;
/**
* @var string
*
* @ORM\Column(name="name", type="string")
*/
private $name;
private string $name;
/**
* @return int

View File

@ -29,7 +29,7 @@ class Flash
*
* @ORM\Column(name="received", type="boolean", nullable=false, options={"default" : false})
*/
private $received = false;
private bool $received = false;
/**
@ -37,5 +37,5 @@ class Flash
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : false})
*/
private $formerlyOwned = false;
private bool $formerlyOwned = false;
}

View File

@ -2,6 +2,8 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
trait FlashTrait
{
use PurchasePriceTrait;
@ -11,91 +13,91 @@ trait FlashTrait
*
* @ORM\Column(name="brand", type="string", nullable=false)
*/
private $brand;
private string $brand;
/**
* @var string
*
* @ORM\Column(name="model", type="string", nullable=false)
*/
private $model;
private string $model;
/**
* @var boolean
*
* @ORM\Column(name="is_auto_flash", type="boolean", nullable=false)
*/
private $isAutoFlash = false;
private bool $isAutoFlash = false;
/**
* @var boolean
*
* @ORM\Column(name="is_ttl", type="boolean", nullable=false)
*/
private $isTtl = false;
private bool $isTtl = false;
/**
* @var string
*
* @ORM\Column(name="ttl_type", type="string", nullable=false)
*/
private $ttlType = 'N / A';
private string $ttlType = 'N / A';
/**
* @var boolean
*
* @ORM\Column(name="is_p_ttl", type="boolean", nullable=false)
*/
private $isPTtl = false;
private bool $isPTtl = false;
/**
* @var string
*
* @ORM\Column(name="p_ttl_type", type="string", nullable=false)
*/
private $pTtlType = 'N / A';
private string $pTtlType = 'N / A';
/**
* @var string
*
* @ORM\Column(name="guide_number", type="string", nullable=true)
*/
private $guideNumber;
private string $guideNumber;
/**
* @var string
*
* @ORM\Column(name="purchase_price", type="money", nullable=true)
*/
private $purchasePrice;
private ?string $purchasePrice;
/**
* @var string
*
* @ORM\Column(name="batteries", type="string", nullable=false)
*/
private $batteries = '4x AA';
private string $batteries = '4x AA';
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private $notes;
private ?string $notes;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", nullable=true)
*/
private $serial;
private ?string $serial;
/**
* Get id
*
* @return integer
*/
public function getId()
public function getId(): int
{
return $this->id;
}
@ -105,7 +107,7 @@ trait FlashTrait
*
* @param string $brand
*
* @return Flash
* @return self
*/
public function setBrand($brand)
{
@ -249,9 +251,9 @@ trait FlashTrait
*
* @param string $pTtlType
*
* @return Flash
* @return self
*/
public function setPTtlType($pTtlType)
public function setPTtlType($pTtlType): self
{
$this->pTtlType = $pTtlType;
@ -273,7 +275,7 @@ trait FlashTrait
*
* @param string $guideNumber
*
* @return Flash
* @return self
*/
public function setGuideNumber($guideNumber)
{
@ -299,7 +301,7 @@ trait FlashTrait
*
* @return Flash
*/
public function setBatteries($batteries)
public function setBatteries($batteries): self
{
$this->batteries = $batteries;
@ -323,7 +325,7 @@ trait FlashTrait
*
* @return Flash
*/
public function setNotes($notes)
public function setNotes($notes): self
{
$this->notes = $notes;
@ -347,7 +349,7 @@ trait FlashTrait
*
* @return Flash
*/
public function setSerial($serial)
public function setSerial($serial): self
{
$this->serial = $serial;
@ -371,7 +373,7 @@ trait FlashTrait
*
* @return Flash
*/
public function setFormerlyOwned($formerlyOwned)
public function setFormerlyOwned($formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
@ -395,7 +397,7 @@ trait FlashTrait
*
* @return Flash
*/
public function setReceived($received)
public function setReceived($received): self
{
$this->received = $received;

View File

@ -11,133 +11,133 @@ trait LensTrait
*
* @ORM\Column(name="brand", type="string", length=64, nullable=true)
*/
private $brand;
private ?string $brand;
/**
* @var string
*
* @ORM\Column(name="coatings", type="string", length=64, nullable=true)
*/
private $coatings;
private ?string $coatings;
/**
* @var string
*
* @ORM\Column(name="product_line", type="string", length=64, nullable=true)
*/
private $productLine;
private ?string $productLine;
/**
* @var string
*
* @ORM\Column(name="model", type="string", length=64, nullable=true)
*/
private $model;
private ?string $model;
/**
* @var string
*
* @ORM\Column(name="min_f_stop", type="string", length=10, nullable=true)
*/
private $minFStop;
private ?string $minFStop;
/**
* @var float
*
* @ORM\Column(name="max_f_stop", type="float", precision=10, scale=0, nullable=true)
*/
private $maxFStop;
private ?float $maxFStop;
/**
* @var integer
*
* @ORM\Column(name="min_focal_length", type="integer", nullable=true)
*/
private $minFocalLength;
private ?int $minFocalLength;
/**
* @var integer
*
* @ORM\Column(name="max_focal_length", type="integer", nullable=true)
*/
private $maxFocalLength;
private ?int $maxFocalLength;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", length=10, nullable=true)
*/
private $serial;
private ?string $serial;
/**
* @var string
*
* @ORM\Column(name="purchase_price", type="money", nullable=true)
*/
private $purchasePrice;
private ?string $purchasePrice;
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private $notes;
private ?string $notes;
/**
* @var string
*
* @ORM\Column(name="image_size", type="string", nullable=false, options={"default"="35mm"})
*/
private $imageSize = '35mm';
private string $imageSize = '35mm';
/**
* @var string
*
* @ORM\Column(name="mount", type="string", length=40, nullable=true)
*/
private $mount;
private ?string $mount;
/**
* @var string
*
* @ORM\Column(name="front_filter_size", type="decimal", precision=10, scale=0, nullable=true)
*/
private $frontFilterSize;
private ?string $frontFilterSize;
/**
* @var string
*
* @ORM\Column(name="rear_filter_size", type="decimal", precision=10, scale=0, nullable=true)
*/
private $rearFilterSize;
private? string $rearFilterSize;
/**
* @var boolean
*
* @ORM\Column(name="is_teleconverter", type="boolean", nullable=false)
*/
private $isTeleconverter = false;
private bool $isTeleconverter = false;
/**
* @var integer
*
* @ORM\Column(name="design_elements", type="smallint", nullable=true)
*/
private $designElements;
private ?int $designElements;
/**
* @var integer
*
* @ORM\Column(name="design_groups", type="smallint", nullable=true)
*/
private $designGroups;
private ?int $designGroups;
/**
* @var integer
*
* @ORM\Column(name="aperture_blades", type="smallint", nullable=true)
*/
private $apertureBlades;
private ?int $apertureBlades;
/**

View File

@ -28,7 +28,7 @@ class PreviouslyOwnedFlash
*
* @ORM\Column(name="received", type="boolean", nullable=false, options={"default" : true})
*/
private $received = true;
private bool $received = true;
/**
@ -36,5 +36,5 @@ class PreviouslyOwnedFlash
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : true})
*/
private $formerlyOwned = true;
private bool $formerlyOwned = true;
}

View File

@ -27,12 +27,12 @@ class PreviouslyOwnedLenses
*
* @ORM\Column(name="received", type="boolean", nullable=false)
*/
private $received = true;
private bool $received = true;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false)
*/
private $formerlyOwned = true;
private bool $formerlyOwned = true;
}

View File

@ -3,19 +3,19 @@
namespace App\ValueObject;
class Money {
private $value;
private float $value;
public function __construct($value)
{
$this->value = (float)str_replace(['$',','], '', $value);
}
public function getValue()
public function getValue(): float
{
return (float)str_replace(['$',','], '', $this->value);
}
public function __toString()
public function __toString(): string
{
return (string)$this->getValue();
}