RedBeanPHP\Repository\Fluid::dispense PHP Метод

dispense() публичный Метод

Dispenses a new bean (a OODBBean Bean Object) of the specified type. Always use this function to get an empty bean object. Never instantiate a OODBBean yourself because it needs to be configured before you can use it with RedBean. This function applies the appropriate initialization / configuration for you.
public dispense ( string $type, string $number = 1, boolean $alwaysReturnArray = FALSE ) : RedBeanPHP\OODBBean
$type string type of bean you want to dispense
$number string number of beans you would like to get
$alwaysReturnArray boolean if TRUE always returns the result as an array
Результат RedBeanPHP\OODBBean
    public function dispense($type, $number = 1, $alwaysReturnArray = FALSE)
    {
        $OODBBEAN = defined('REDBEAN_OODBBEAN_CLASS') ? REDBEAN_OODBBEAN_CLASS : '\\RedBeanPHP\\OODBBean';
        $beans = array();
        for ($i = 0; $i < $number; $i++) {
            $bean = new $OODBBEAN();
            $bean->initializeForDispense($type, $this->oodb->getBeanHelper());
            $this->check($bean);
            $this->oodb->signal('dispense', $bean);
            $beans[] = $bean;
        }
        return count($beans) === 1 && !$alwaysReturnArray ? array_pop($beans) : $beans;
    }