Skip to content

Commit

Permalink
modern php features
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyraul committed Jul 31, 2024
1 parent 8bc1078 commit 1f3151a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 40 deletions.
11 changes: 9 additions & 2 deletions src/Jeeves/Generators/Crud/Interfaces/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function genModelInterface(
bool $withStore = false,
string $phpVersion = PHP_VERSION
): PhpNamespace {
$hasTypedConst = $this->hasTypedConst($phpVersion);
$namespace = new PhpNamespace($rootNamespace . '\Api\Data');
$interface = $namespace->addInterface($className);

Expand All @@ -27,7 +28,10 @@ public function genModelInterface(
if ($cacheTag !== null) {
$namespace->addUse('\Magento\Framework\DataObject\IdentityInterface');
$interface->setExtends('\Magento\Framework\DataObject\IdentityInterface');
$interface->addConstant('CACHE_TAG', $cacheTag)->setVisibility('public');
$ctag = $interface->addConstant('CACHE_TAG', $cacheTag)->setVisibility('public');
if ($hasTypedConst) {
$ctag->setType('string');
}
}

if ($withStore) {
Expand All @@ -48,7 +52,10 @@ public function genModelInterface(
if (isset($value['identity']) && $value['identity'] === true) {
$generated = true;
}
$interface->addConstant(strtoupper($name), strtolower($name))->setPublic();
$c = $interface->addConstant(strtoupper($name), strtolower($name))->setPublic();
if ($hasTypedConst) {
$c->setType('string');
}
$method = $this->snakeCaseToUpperCamelCase($name);
$get = $interface->addMethod('get' . $method)
->setVisibility('public');
Expand Down
14 changes: 7 additions & 7 deletions test/Expectations/Crud/83/v1/Api/Data/CardInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/
interface CardInterface extends IdentityInterface
{
public const CACHE_TAG = 'samp_card';
public const CARD_ID = 'card_id';
public const TITLE = 'title';
public const CODE = 'code';
public const CATEGORY_ID = 'category_id';
public const IS_ACTIVE = 'is_active';
public const STORE_ID = 'store_id';
public const string CACHE_TAG = 'samp_card';
public const string CARD_ID = 'card_id';
public const string TITLE = 'title';
public const string CODE = 'code';
public const string CATEGORY_ID = 'category_id';
public const string IS_ACTIVE = 'is_active';
public const string STORE_ID = 'store_id';

/**
* Get card id
Expand Down
20 changes: 10 additions & 10 deletions test/Expectations/Crud/83/v1/Api/Data/CartItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

interface CartItemInterface
{
public const CART_ID = 'cart_id';
public const IS_ACTIVE = 'is_active';
public const DELIVERY_DATE = 'delivery_date';
public const CITY = 'city';
public const CUSTOMER_GROUP = 'customer_group';
public const DESCRIPTION = 'description';
public const CREATED_AT = 'created_at';
public const UPDATED_AT = 'updated_at';
public const DISCOUNT = 'discount';
public const PRICE = 'price';
public const string CART_ID = 'cart_id';
public const string IS_ACTIVE = 'is_active';
public const string DELIVERY_DATE = 'delivery_date';
public const string CITY = 'city';
public const string CUSTOMER_GROUP = 'customer_group';
public const string DESCRIPTION = 'description';
public const string CREATED_AT = 'created_at';
public const string UPDATED_AT = 'updated_at';
public const string DISCOUNT = 'discount';
public const string PRICE = 'price';

/**
* Get cart id
Expand Down
22 changes: 11 additions & 11 deletions test/Expectations/Crud/83/v1/Api/Data/ColumnsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

interface ColumnsInterface
{
public const ID = 'id';
public const IS_ACTIVE = 'is_active';
public const HAS_FLAG = 'has_flag';
public const MERGE_DATE = 'merge_date';
public const DISCOUNT = 'discount';
public const COST = 'cost';
public const PRICE = 'price';
public const NAME = 'name';
public const DESCRIPTION = 'description';
public const CREATED_AT = 'created_at';
public const UPDATED_AT = 'updated_at';
public const string ID = 'id';
public const string IS_ACTIVE = 'is_active';
public const string HAS_FLAG = 'has_flag';
public const string MERGE_DATE = 'merge_date';
public const string DISCOUNT = 'discount';
public const string COST = 'cost';
public const string PRICE = 'price';
public const string NAME = 'name';
public const string DESCRIPTION = 'description';
public const string CREATED_AT = 'created_at';
public const string UPDATED_AT = 'updated_at';

/**
* Get id
Expand Down
14 changes: 7 additions & 7 deletions test/Expectations/Crud/83/v1/Api/Data/PosterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/
interface PosterInterface extends IdentityInterface
{
public const CACHE_TAG = 'samp_poster';
public const ID = 'id';
public const NAME = 'name';
public const SUBNAME = 'subname';
public const FAMILY = 'family';
public const IS_ACTIVE = 'is_active';
public const PRODUCT_ID = 'product_id';
public const string CACHE_TAG = 'samp_poster';
public const string ID = 'id';
public const string NAME = 'name';
public const string SUBNAME = 'subname';
public const string FAMILY = 'family';
public const string IS_ACTIVE = 'is_active';
public const string PRODUCT_ID = 'product_id';

/**
* Get id
Expand Down
6 changes: 3 additions & 3 deletions test/Expectations/Crud/83/v1/Api/Data/TicketInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

interface TicketInterface
{
public const TICKET_ID = 'ticket_id';
public const NAME = 'name';
public const IS_ACTIVE = 'is_active';
public const string TICKET_ID = 'ticket_id';
public const string NAME = 'name';
public const string IS_ACTIVE = 'is_active';

/**
* Get ticket id
Expand Down

0 comments on commit 1f3151a

Please sign in to comment.