<?php

namespace Roots\Sage;

/**
 * Utility class which takes an array of conditional tags (or any function which returns a boolean)
 * and returns `true` if *any* of them are `true`, and `false` otherwise.
 *
 * @param array list of conditional tags (http://codex.wordpress.org/Conditional_Tags)
 *        or custom function which returns a boolean
 *
 * @return boolean
 */
class ConditionalTagCheck {
  private $conditionals;

  public $result = true;

  public function __construct($conditionals = []) {
    $this->conditionals = $conditionals;

    $conditionals = array_map([$this, 'checkConditionalTag'], $this->conditionals);

    if (in_array(true, $conditionals)) {
      $this->result = false;
    }
  }

  private function checkConditionalTag($conditional) {
    if (is_array($conditional)) {
      list($tag, $args) = $conditional;
    } else {
      $tag = $conditional;
      $args = false;
    }

    if (function_exists($tag)) {
      return $args ? $tag($args) : $tag();
    } else {
      return false;
    }
  }
}

<?php

namespace Roots\Sage;

/**
 * Utility class which takes an array of conditional tags (or any function which returns a boolean)
 * and returns `false` if *any* of them are `true`, and `true` otherwise.
 *
 * @param array list of conditional tags (http://codex.wordpress.org/Conditional_Tags)
 *        or custom function which returns a boolean
 *
 * @return boolean
 */
class ConditionalTagCheck {
  private $conditionals;

  public $result = true;

  public function __construct($conditionals = []) {
    $this->conditionals = $conditionals;

    $conditionals = array_map([$this, 'checkConditionalTag'], $this->conditionals);

    if (in_array(true, $conditionals)) {
      $this->result = false;
    }
  }

  private function checkConditionalTag($conditional) {
    if (is_array($conditional)) {
      list($tag, $args) = $conditional;
    } else {
      $tag = $conditional;
      $args = false;
    }

    if (function_exists($tag)) {
      return $args ? $tag($args) : $tag();
    } else {
      return false;
    }
  }
}

Adjust comments on ConditionalTagCheck to match actual functionality.
Adjust comments on ConditionalTagCheck to match actual functionality.

The check returns false, if any of it's tags are true, not vise versa.
