Skip to content

michaelkeiluweit/oe62_component_random_number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

random-number

Example component service for OXID eShop 6.2

Install as package

composer require michaelkeiluweit/random-number

Example usage

<?php

use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use MichaelKeiluweit\RandomNumber\RandomNumberInterface;

require_once 'bootstrap.php';

/** @var RandomNumberInterface $randomNumber */
$randomNumber = ContainerFactory::getInstance()->getContainer()->get(RandomNumberInterface::class);

$number = $randomNumber->shuffle();
echo PHP_EOL;
echo 'random number: ' . $number . PHP_EOL;
echo 'number type: ' . gettype($number) . PHP_EOL;
echo 'object type: ' . get_class($randomNumber) . PHP_EOL . PHP_EOL;

Switch from integer to float

To get a random float number, open the file random-number/src/services.yaml and replace the line

class: MichaelKeiluweit\RandomNumber\RandomIntegerNumber

with

class: MichaelKeiluweit\RandomNumber\RandomFloatNumber

After that, execute the command composer update. Now the service will provide a random float number.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages