mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-22 10:11:04 +01:00
Added drafts for entity interfaces
This commit is contained in:
parent
4845deddc6
commit
6fcef40e10
16
src/entity/color/ColorInterface.php
Normal file
16
src/entity/color/ColorInterface.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace entity\color;
|
||||
|
||||
/**
|
||||
* In a real Application color would be saved in the database
|
||||
* Otherwise it's agains "Normalisierung" ;)
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface ColorInterface
|
||||
{
|
||||
public function setColor(string $color):void;
|
||||
|
||||
public function getColor():string;
|
||||
}
|
||||
|
41
src/entity/currency/CurrencyInterface.php
Normal file
41
src/entity/currency/CurrencyInterface.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace entity\currency;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface CurrencyInterface
|
||||
{
|
||||
/**
|
||||
* Sets the value of the currency
|
||||
* @param int $cents
|
||||
*/
|
||||
public function setCents(int $cents):void;
|
||||
|
||||
/**
|
||||
* Returns the currency value in cents
|
||||
* @return int
|
||||
*/
|
||||
public function getCents():int;
|
||||
|
||||
/**
|
||||
* Returns the currency value as float (rounded on two decimal behind the )
|
||||
* @return float
|
||||
*/
|
||||
public function getFloat():float;
|
||||
|
||||
/**
|
||||
* Returns the name of the currency
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string;
|
||||
|
||||
/**
|
||||
* Returns the symbol of the currency
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol():string;
|
||||
}
|
||||
|
26
src/entity/image/ImageInterface.php
Normal file
26
src/entity/image/ImageInterface.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace entity\image;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface ImageInterface
|
||||
{
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function setImage(string $path):void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImage():string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImageThumbnail():string;
|
||||
}
|
||||
|
59
src/entity/order/OrderInterface.php
Normal file
59
src/entity/order/OrderInterface.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace entity\order;
|
||||
|
||||
use entity\product\ProductInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use entity\user\UserInterface;
|
||||
|
||||
/**
|
||||
* Status in this class is bool
|
||||
* True when order is finished
|
||||
* Fales when order is open
|
||||
*
|
||||
* In a real application an entity status would be helpfull ;)
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface OrderInterface
|
||||
{
|
||||
/**
|
||||
* @param ProductInterface $product
|
||||
*/
|
||||
public function addProduct(ProductInterface $product):void;
|
||||
|
||||
/**
|
||||
* @param ProductInterface $product
|
||||
*/
|
||||
public function removeProduct(ProductInterface $product):void;
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getProducts():ArrayCollection;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId():int;
|
||||
|
||||
/**
|
||||
* @return UserInterface
|
||||
*/
|
||||
public function getCustomer():UserInterface;
|
||||
|
||||
/**
|
||||
* @param UserInterface $customer
|
||||
*/
|
||||
public function setCutomer(UserInterface $customer);
|
||||
|
||||
/**
|
||||
* @param bool $status
|
||||
*/
|
||||
public function setStatus(bool $status):void;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getStatus():bool;
|
||||
}
|
12
src/entity/payment/PaymentInterface.php
Normal file
12
src/entity/payment/PaymentInterface.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace entity\payment;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface PaymentInterface
|
||||
{
|
||||
}
|
||||
|
31
src/entity/price/PriceInterface.php
Normal file
31
src/entity/price/PriceInterface.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace entity\price;
|
||||
|
||||
use entity\currency\CurrencyInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface PriceInterface
|
||||
{
|
||||
/**
|
||||
* Sets the price
|
||||
* @param CurrencyInterface $price
|
||||
*/
|
||||
public function setPrice(CurrencyInterface $price):void;
|
||||
|
||||
/**
|
||||
* Returns the netto price
|
||||
* @return int
|
||||
*/
|
||||
public function getNetto():CurrencyInterface;
|
||||
|
||||
/**
|
||||
* Returns the gross price
|
||||
* @return int
|
||||
*/
|
||||
public function getGross():CurrencyInterface;
|
||||
}
|
||||
|
63
src/entity/product/ProductInterface.php
Normal file
63
src/entity/product/ProductInterface.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
namespace entity\product;
|
||||
|
||||
use entity\price\PriceInterface;
|
||||
use entity\image\ImageInterface;
|
||||
use entity\color\ColorInterface;
|
||||
|
||||
/**
|
||||
* Attention:
|
||||
* This interface containes the accercors for color.
|
||||
* In a real application I wouldn't hardcode acceccors for a special attribute into the product.
|
||||
* Instead I would make an ArrayCollection $attributes which containes all of the product attributes.
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface ProductInterface
|
||||
{
|
||||
/**
|
||||
* @return PriceInterface
|
||||
*/
|
||||
public function getPrice():PriceInterface;
|
||||
|
||||
/**
|
||||
* @param PriceInterface $price
|
||||
*/
|
||||
public function setPrice(PriceInterface $price):void;
|
||||
|
||||
/**
|
||||
* @param ImageInterface $image
|
||||
*/
|
||||
public function setImage(ImageInterface $image):void;
|
||||
|
||||
/**
|
||||
* @return ImageInterface
|
||||
*/
|
||||
public function getImage():ImageInterface;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name):void;
|
||||
|
||||
/**
|
||||
* @return ColorInterface
|
||||
*/
|
||||
public function getColor():ColorInterface;
|
||||
|
||||
/**
|
||||
* @param ColorInterface $color
|
||||
*/
|
||||
public function setColor(ColorInterface $color):void;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId():int;
|
||||
}
|
||||
|
49
src/entity/user/UserInterface.php
Normal file
49
src/entity/user/UserInterface.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace entity\user;
|
||||
|
||||
/**
|
||||
* Theoreticly you could make an own entity for name
|
||||
* (Depends on the use case.)
|
||||
* In this case I just assume that the user just has an username, which is just a string
|
||||
* The same counts for email ;) -> In a real application: Entity Email ;)
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface UserInterface
|
||||
{
|
||||
/**
|
||||
* @param string $hash
|
||||
*/
|
||||
public function setPasswordHash(string $hash):void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPasswordHash():string;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name):void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string;
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*/
|
||||
public function setEmail(string $email):void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail():string;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId():int;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user