Skip to content

Commit

Permalink
Adding Product class
Browse files Browse the repository at this point in the history
  • Loading branch information
btafforeau committed Nov 24, 2023
1 parent bfe4db5 commit d3b9efc
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Category/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

class Category
{
const DIGITAL_GOODS = "DIGITAL_GOODS";
const PHYSICAL_GOODS = "PHYSICAL_GOODS";
const DONATION = "DONATION";
}
28 changes: 28 additions & 0 deletions src/Product/Exception/ProductException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\Product\Exception;

use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;

class ProductException extends PsCheckoutException
{

}
126 changes: 126 additions & 0 deletions src/Product/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\Product;

use PrestaShop\Module\PrestashopCheckout\Amount\Amount;

class Product
{
/** @var string */
private $name;

/** @var Amount */
private $unitPrice;

/** @var int */
private $quantity;

/** @var boolean */
private $isInStock;

/** @var boolean */
private $isAvailableForOrder;

/** @var string */
private $sku;

/** @var string */
private $category;

/** @var Amount */
private $tax;

public function __construct($name, $unitPrice, $quantity, $isInStock, $isAvailableForOrder, $sku = '', $category = '', $tax = null)
{
$this->name = $name;
$this->unitPrice = $unitPrice;
$this->quantity = $quantity;
$this->isInStock = $isInStock;
$this->isAvailableForOrder = $isAvailableForOrder;
$this->sku = $sku;
$this->category = $category;
$this->tax = $tax;
}

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @return Amount
*/
public function getUnitPrice()
{
return $this->unitPrice;
}

/**
* @return string
*/
public function getQuantity()
{
return $this->quantity;

Check failure on line 84 in src/Product/Product.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0.0)

Method PrestaShop\Module\PrestashopCheckout\Product\Product::getQuantity() should return string but returns int.

Check failure on line 84 in src/Product/Product.php

View workflow job for this annotation

GitHub Actions / PHPStan (latest)

Method PrestaShop\Module\PrestashopCheckout\Product\Product::getQuantity() should return string but returns int.
}

/**
* @return bool
*/
public function isInStock()
{
return $this->isInStock;
}

/**
* @return bool
*/
public function isAvailableForOrder()
{
return $this->isAvailableForOrder;
}

/**
* @return string
*/
public function getSku()
{
return $this->sku;
}

/**
* @return string
*/
public function getCategory()
{
return $this->category;
}

/**
* @return Amount
*/
public function getTax()
{
return $this->tax;
}
}

0 comments on commit d3b9efc

Please sign in to comment.