| 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 |
/** |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
private $type; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
private $category; |
| 22 |
|
| 23 |
/** |
| 24 |
* @param string $type |
| 25 |
*/ |
| 26 |
public function setLogType($type) |
| 27 |
{ |
| 28 |
$this->type = $type; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* @param string $category |
| 33 |
*/ |
| 34 |
public function setLogCategory($category) |
| 35 |
{ |
| 36 |
$this->category = $category; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* @param string $category |
| 41 |
*/ |
| 42 |
public function setLogSource($source) |
| 43 |
{ |
| 44 |
$this->source = $source; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* @return string |
| 49 |
*/ |
| 50 |
public function getLogType() |
| 51 |
{ |
| 52 |
if ('random' === $this->type) { |
| 53 |
return $this->randomLogType(); |
| 54 |
} |
| 55 |
|
| 56 |
return $this->type; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* @return string |
| 61 |
*/ |
| 62 |
public function getLogCategory() |
| 63 |
{ |
| 64 |
if ('random' === $this->category) { |
| 65 |
return $this->randomLogCategory(); |
| 66 |
} |
| 67 |
|
| 68 |
return $this->category; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* @return string |
| 73 |
*/ |
| 74 |
public function getLogSource() |
| 75 |
{ |
| 76 |
if ('random' === $this->source) { |
| 77 |
return $this->faker->sentence($nbWords = 3); |
| 78 |
} |
| 79 |
|
| 80 |
return $this->source; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Donor definition |
| 85 |
* |
| 86 |
* @since 1.0.0 |
| 87 |
* @return array |
| 88 |
*/ |
| 89 |
public function definition() |
| 90 |
{ |
| 91 |
return [ |
| 92 |
'type' => $this->getLogType(), |
| 93 |
'message' => $this->faker->sentence($nbWords = 6), |
| 94 |
'category' => $this->getLogCategory(), |
| 95 |
'source' => $this->getLogSource(), |
| 96 |
'context' => [ |
| 97 |
'Info' => $this->faker->sentence($nbWords = 6), |
| 98 |
], |
| 99 |
]; |
| 100 |
} |
| 101 |
} |
| 102 |
|