DonationFactory.php
5 years ago
DonationFormFactory.php
5 years ago
DonorFactory.php
5 years ago
LogFactory.php
5 years ago
PageFactory.php
5 years ago
RevenueFactory.php
5 years ago
LogFactory.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\TestData\Factories; |
| 4 | |
| 5 | use Give\TestData\Framework\Factory; |
| 6 | |
| 7 | /** |
| 8 | * Class LogFactory |
| 9 | * @package Give\TestData\Factories |
| 10 | */ |
| 11 | class LogFactory extends Factory { |
| 12 | /** |
| 13 | * @var string |
| 14 | */ |
| 15 | private $type; |
| 16 | |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | private $category; |
| 21 | |
| 22 | /** |
| 23 | * @param string $type |
| 24 | */ |
| 25 | public function setLogType( $type ) { |
| 26 | $this->type = $type; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @param string $category |
| 31 | */ |
| 32 | public function setLogCategory( $category ) { |
| 33 | $this->category = $category; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @param string $category |
| 38 | */ |
| 39 | public function setLogSource( $source ) { |
| 40 | $this->source = $source; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @return string |
| 45 | */ |
| 46 | public function getLogType() { |
| 47 | if ( 'random' === $this->type ) { |
| 48 | return $this->randomLogType(); |
| 49 | } |
| 50 | |
| 51 | return $this->type; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @return string |
| 56 | */ |
| 57 | public function getLogCategory() { |
| 58 | if ( 'random' === $this->category ) { |
| 59 | return $this->randomLogCategory()(); |
| 60 | } |
| 61 | |
| 62 | return $this->category; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return string |
| 67 | */ |
| 68 | public function getLogSource() { |
| 69 | if ( 'random' === $this->source ) { |
| 70 | return $this->faker->sentence( $nbWords = 3 ); |
| 71 | } |
| 72 | |
| 73 | return $this->source; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Donor definition |
| 78 | * |
| 79 | * @return array |
| 80 | * @since 1.0.0 |
| 81 | */ |
| 82 | public function definition() { |
| 83 | return [ |
| 84 | 'type' => $this->getLogType(), |
| 85 | 'message' => $this->faker->sentence( $nbWords = 6 ), |
| 86 | 'category' => $this->getLogCategory(), |
| 87 | 'source' => $this->getLogSource(), |
| 88 | 'context' => [ |
| 89 | 'Info' => $this->faker->sentence( $nbWords = 6 ), |
| 90 | ], |
| 91 | ]; |
| 92 | } |
| 93 | } |
| 94 |