Server IP : 192.158.238.246 / Your IP : 3.144.226.0 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/task/7779/cwd/plugins/give/src/TestData/Factories/ |
Upload File : |
<?php namespace Give\TestData\Factories; use Give\TestData\Framework\Factory; /** * Class DonationFormFactory * @package Give\TestData\Factories */ class DonationFormFactory extends Factory { /** * @var bool */ private $donationGoal; /** * @var bool */ private $termsAndConditions; /** * @var string */ private $template; /** * @var string[] */ private $templates = ['sequoia', 'legacy']; /** * @param string $template * * @return bool */ public function checkFormTemplate($template) { if ('random' === $template) { return true; } return in_array($template, $this->templates); } /** * @param string $template */ public function setFormTemplate($template) { $this->template = $template; } /** * @return string */ public function getFormTemplate() { if ('random' === $this->template) { return $this->randomDonationTemplate(); } return $this->template; } /** * @return string */ public function randomDonationTemplate() { return $this->faker->randomElement($this->templates); } /** * @param bool $generate */ public function setDonationFormGoal($generate) { $this->donationGoal = (bool)$generate; } /** * @return false|string */ public function getDonationGoal() { if (is_null($this->donationGoal) || ! $this->donationGoal) { return false; } return $this->randomGoal(); } /** * @param bool $generate */ public function setTermsAndConditions($generate) { $this->termsAndConditions = (bool)$generate; } /** * @return array */ public function getTermsAndConditions() { if (is_null($this->termsAndConditions) || ! $this->termsAndConditions) { return []; } return [ 'label' => $this->faker->catchPhrase(), 'text' => $this->faker->text(), ]; } /** * Donor definition * * @since 1.0.0 * @return array */ public function definition() { $title = $this->faker->catchPhrase(); return [ 'post_title' => $title, 'post_name' => sanitize_title($title), 'post_author' => $this->randomAuthor(), 'post_date' => date('Y-m-d H:i:s'), 'donation_goal' => $this->getDonationGoal(), 'donation_terms' => $this->getTermsAndConditions(), 'form_template' => $this->getFormTemplate(), 'random_amount' => $this->randomAmount(), ]; } }