earmark icon indicating copy to clipboard operation
earmark copied to clipboard

null passed to construct, assumes config values

Open poing opened this issue 4 years ago • 2 comments

$earmark = new Earmark(null, null, null, 20000, null);  // Start with 20000

Running $earmark->get() returns ECHO00020000 instead of 20000 as I have set it in the config to prefix with ECHO with a padding of 8. Is there a better way to handle this? As the extension is an integer value in the database it will not accept it.


This is caused by the construct() prioritizing values from the config when null are passed to the method().

poing avatar Oct 23 '20 14:10 poing

Part of the fix, requires passing the config values to the singleton in EarmarkServiceProvider.php.

poing avatar Oct 23 '20 14:10 poing

Need to impliment and test, but the fix will probably be:

        // @codeCoverageIgnoreStart
        //Poing\Earmark\Http\Controllers
        $this->app->singleton('earmark', function () {
-           return new Serial;
+           return new Serial(CONFIG VALUES);
        });

Passing the configuration values to the singleton

-and-

removing null handling from the construct().

poing avatar Oct 25 '20 03:10 poing