super-powers/src/11572d9b-e3d5-4b29-904c-961.../code.power

28 lines
604 B
Plaintext

/**
* Retrieves number of values (or sub-array) from the storage using multiple keys.
*
* @param string $path Storage path (e.g. vdm.content.builder)
*
* @throws \InvalidArgumentException If any of the path values are not a number or string.
* @return int The number of values
* @since 3.2.0
*/
public function count(string $path): int
{
if (($values = $this->get($path)) === null)
{
return 0;
}
if (is_array($values))
{
return count($values);
}
if (is_object($values))
{
return count((array) $values);
}
return 1;
}