for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace hiqdev\billing\hiapi\type;
use hiqdev\php\billing\type\Type;
use hiqdev\php\billing\type\TypeInterface;
class TypeSemantics
{
private const MONTHLY = 'monthly';
private const OVERUSE = 'overuse';
private const DISCOUNT = 'discount';
/**
* // TODO: Probably not the best place for this method
*
* @return TypeInterface
*/
public function createMonthlyType(): TypeInterface
return new Type(null, self::MONTHLY . ',' . self::MONTHLY);
}
* @param TypeInterface $type
* @return bool
public function isMonthly(TypeInterface $type): bool
return $this->groupName($type) === self::MONTHLY;
public function isDiscount(TypeInterface $type): bool
return $this->groupName($type) === self::DISCOUNT;
public function isOveruse(TypeInterface $type): bool
return $this->groupName($type) === self::OVERUSE;
* @return string
public function groupName(TypeInterface $type): string
$name = $type->getName();
if (strpos($name, ',') !== false) {
[$name,] = explode(',', $name, 2);
return $name;
return $name
null
string