| Conditions | 6 |
| Paths | 18 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | 8 | public function fakeData($options = null, $count = null) |
|
| 39 | { |
||
| 40 | 8 | if (is_null($options)) { |
|
| 41 | 1 | $options = self::FAKE_RESOURCE_OBJECT | self::FAKE_COLLECTION; |
|
| 42 | 1 | $count = 5; |
|
| 43 | } |
||
| 44 | |||
| 45 | 8 | $faker = \Faker\Factory::create(); |
|
| 46 | |||
| 47 | 8 | if ($options & self::FAKE_CAN_BE_NULL) { |
|
| 48 | 1 | if ($faker->boolean) { |
|
| 49 | 1 | $this->setData(null); |
|
| 50 | 1 | return $this; |
|
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | 8 | $class = (($options & self::FAKE_RESOURCE_IDENTIFIER) == self::FAKE_RESOURCE_IDENTIFIER) ? |
|
| 55 | 8 | ResourceIdentifierFactory::class : ResourceObjectFactory::class; |
|
| 56 | |||
| 57 | 8 | if ($options & self::FAKE_COLLECTION) { |
|
| 58 | 6 | $data = (new CollectionFactory)->fake($options, $count); |
|
| 59 | } else { |
||
| 60 | 2 | $data = (new $class)->fake(); |
|
| 61 | } |
||
| 62 | 8 | $this->setData($data); |
|
| 63 | |||
| 64 | 8 | return $this; |
|
| 65 | } |
||
| 67 |