# billingo/4.2.9/src/Traits/WithFactory.php

Billingo Official for WooCommerce, version 4.2.9. 36 lines.

- Page: https://pluginprobe.com/plugins/billingo/4.2.9/code/src/Traits/WithFactory.php
- Raw: https://pluginprobe.com/plugins/billingo/4.2.9/raw/src/Traits/WithFactory.php
- Modified: 2025-05-26T04:53:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/billingo/4.2.9/code/src/Traits/WithFactory.php#L10-L20`.

```php
<?php

namespace App\Billingo\Traits;

use App\Billingo\Models\BillingoModel;
use App\Billingo\Service\BillingoCollection;

trait WithFactory
{
    public static function factory($round = 1): null|BillingoModel|BillingoCollection
    {
        if ($round < 1) {
            $round = 1;
        }

        $callerName = static::class;

        $factoryName = "App\Billingo\Factories\\" . classBasename($callerName) . 'Factory';

        if (!class_exists($factoryName)) {

            return null;
        }

        $fakers = [];

        for ($i = 0; $i < $round; $i++):
            $fakers[] = new $callerName((new $factoryName)->definition());
        endfor;

        $fakers = billingoCollection($fakers);

        return $round === 1 ? $fakers->first() : $fakers;
    }
}

```
