Jump to content

FilenameArray class to implement Countable interface


hwmaier
 Share

Recommended Posts

It would be beneficial if the FilenameArray class would have a count() method.
 
Suggested implementation:
class FilenameArray implements IteratorAggregate, Countable {

...

/**
 * Returns the number of items in this FilenameArray.
 *
 * Fulfills Countable interface.
 *
 * @return int
 */
 public function count() {
     return count($this->data);
 }
Rationale:
 
A count method can be used to check if any scripts or stylesheets are configured as shown in the following example:
 
<?if (count($config->scripts)):?>
    <script type="text/javascript" src="<?=AllInOneMinify::JS($config->scripts?>"></script>
<?endif?>

The current implementation of FilenameArray does not implement the Countable interface and count() will return a 1 regardless of the number of elements in the FilenameArray.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...