query = $query; } // getUserMerchant public function getOneByUser(UserInterface $user) { $query = $this->query->create(); $query ->filterByMerchant($this->merchant) ->filterByUser($user); return $query->findOne(); } public function isCreditActive(UserMerchantInterface $userMerchant = null) { if (!$userMerchant || ($userMerchant && !$userMerchant->isCreditActive())) { return false; } return true; } public function isCreditActiveByUser(UserInterface $user) { $userMerchant = $this->getOneByUser($user); return $this->isCreditActive($userMerchant); } public function isCreditSufficientToPay(UserMerchantInterface $userMerchant, float $amount) { if ($this->isCreditActive($userMerchant) && $userMerchant->getCredit() >= $amount) { return true; } return false; } }