Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Webkul\CartRule\Repositories; use Webkul\Core\Eloquent\Repository; clas..
Decoded Output download
<?php
namespace Webkul\CartRule\Repositories;
use Webkul\Core\Eloquent\Repository;
class CartRuleCouponRepository extends Repository
{
/**
* @var array
*/
protected $charset = [
'alphanumeric' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
'alphabetical' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'numeric' => '0123456789',
];
/**
* Specify Model class name
*/
public function model(): string
{
return 'Webkul\CartRule\Contracts\CartRuleCoupon';
}
/**
* Creates coupons for cart rule
*/
public function generateCoupons(array $data, int $cartRuleId): void
{
$cartRule = app('Webkul\CartRule\Repositories\CartRuleRepository')->findOrFail($cartRuleId);
for ($i = 0; $i < $data['coupon_qty']; $i++) {
parent::create([
'cart_rule_id' => $cartRuleId,
'code' => $data['code_prefix'].$this->getRandomString($data['code_format'], $data['code_length']).$data['code_suffix'],
'usage_limit' => $cartRule->uses_per_coupon ?? 0,
'usage_per_customer' => $cartRule->usage_per_customer ?? 0,
'is_primary' => 0,
'expired_at' => $cartRule->ends_till ?: null,
]);
}
}
/**
* Creates coupons for cart rule
*/
public function getRandomString(string $format, int $length): string
{
$couponCode = '';
for ($i = 0; $i < $length; $i++) {
$couponCode .= $this->charset[$format][rand(0, strlen($this->charset[$format]) - 1)];
}
return $couponCode;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Webkul\CartRule\Repositories;
use Webkul\Core\Eloquent\Repository;
class CartRuleCouponRepository extends Repository
{
/**
* @var array
*/
protected $charset = [
'alphanumeric' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
'alphabetical' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'numeric' => '0123456789',
];
/**
* Specify Model class name
*/
public function model(): string
{
return 'Webkul\CartRule\Contracts\CartRuleCoupon';
}
/**
* Creates coupons for cart rule
*/
public function generateCoupons(array $data, int $cartRuleId): void
{
$cartRule = app('Webkul\CartRule\Repositories\CartRuleRepository')->findOrFail($cartRuleId);
for ($i = 0; $i < $data['coupon_qty']; $i++) {
parent::create([
'cart_rule_id' => $cartRuleId,
'code' => $data['code_prefix'].$this->getRandomString($data['code_format'], $data['code_length']).$data['code_suffix'],
'usage_limit' => $cartRule->uses_per_coupon ?? 0,
'usage_per_customer' => $cartRule->usage_per_customer ?? 0,
'is_primary' => 0,
'expired_at' => $cartRule->ends_till ?: null,
]);
}
}
/**
* Creates coupons for cart rule
*/
public function getRandomString(string $format, int $length): string
{
$couponCode = '';
for ($i = 0; $i < $length; $i++) {
$couponCode .= $this->charset[$format][rand(0, strlen($this->charset[$format]) - 1)];
}
return $couponCode;
}
}
Function Calls
None |
Stats
MD5 | db3a9b3726711137d81e60d1add98684 |
Eval Count | 0 |
Decode Time | 96 ms |