public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'include'                   => [],
            'exclude'                   => [],
            'exclude_deprecated_levels' => true,
            'no_cache'                  => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['include']                   = (array) $args['include'];
        $args['exclude']                   = (array) $args['exclude'];
        $args['exclude_deprecated_levels'] = (bool) $args['exclude_deprecated_levels'];
        $args['no_cache']                  = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total caps in the query.

        $caps = $this->collectAll(); // All possible caps.

        $caps = $args['include'] ? array_intersect_key($caps, array_fill_keys($args['include'], true)) : $caps;
        $caps = $args['exclude'] ? array_diff_key($caps, array_fill_keys($args['exclude'], true)) : $caps;
        $caps = $args['exclude_deprecated_levels'] ? array_diff_key($caps, array_fill_keys($this->deprecated_levels, true)) : $caps;

        return $total = count($caps);
    }
public function total(array $args = []): int
    {
        // Establish args.

        $default_args = [
            // Also used by {@link all()}.
            'include'                   => [],
            'exclude'                   => [],
            'exclude_deprecated_levels' => true,
            'no_cache'                  => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        $args['include']                   = (array) $args['include'];
        $args['exclude']                   = (array) $args['exclude'];
        $args['exclude_deprecated_levels'] = (bool) $args['exclude_deprecated_levels'];
        $args['no_cache']                  = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($total = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $total; // Already cached this.
        }
        // Establish total caps in the query.

        $caps = $this->collectAll(); // All possible caps.

        $caps = $args['include'] ? array_intersect_key($caps, array_fill_keys($args['include'], true)) : $caps;
        $caps = $args['exclude'] ? array_diff_key($caps, array_fill_keys($args['exclude'], true)) : $caps;
        $caps = $args['exclude_deprecated_levels'] ? array_diff_key($caps, array_fill_keys($this->deprecated_levels, true)) : $caps;

        return $total = count($caps);
    }
public function total ( array $ args = [ ] ) : int { // Establish args. $ default_args = [ // Also used by {@link all()}. 'include' => [ ] , 'exclude' => [ ] , 'exclude_deprecated_levels' => true , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'include' ] = ( array ) $ args [ 'include' ] ; $ args [ 'exclude' ] = ( array ) $ args [ 'exclude' ] ; $ args [ 'exclude_deprecated_levels' ] = ( bool ) $ args [ 'exclude_deprecated_levels' ] ; $ args [ 'no_cache' ] = ( bool ) $ args [ 'no_cache' ] ; // Check cache; already did this query? $ cache_keys = $ args ; // Keys to consider when checking the cache. unset ( $ cache_keys [ 'no_cache' ] ) ; // Cache key exclusions. if ( ( $ total = & $ this -> cacheKey ( __FUNCTION__ , $ cache_keys ) ) !== null && ! $ args [ 'no_cache' ] ) { return $ total ; // Already cached this. } // Establish total caps in the query. $ caps = $ this -> collectAll ( ) ; // All possible caps. $ caps = $ args [ 'include' ] ? array_intersect_key ( $ caps , array_fill_keys ( $ args [ 'include' ] , true ) ) : $ caps ; $ caps = $ args [ 'exclude' ] ? array_diff_key ( $ caps , array_fill_keys ( $ args [ 'exclude' ] , true ) ) : $ caps ; $ caps = $ args [ 'exclude_deprecated_levels' ] ? array_diff_key ( $ caps , array_fill_keys ( $ this -> deprecated_levels , true ) ) : $ caps ; return $ total = count ( $ caps ) ; }
Total caps.

@since 160524 Cap utils.

@param array $args Behavioral args.

@return int Total caps.
Total caps .