MathPHP\SetTheory\Set::isSubset PHP Méthode

isSubset() public méthode

Subset (A ⊆ B) Is the set a subset of the other set? In other words, does the other set contain all the elements of the set?
public isSubset ( Set $B ) : boolean
$B Set
Résultat boolean
    public function isSubset(Set $B) : bool
    {
        $B_array = $B->asArray();
        $A∩B = array_intersect_key($this->A, $B_array);
        $A∖B = array_diff_key($this->A, $B_array);
        return count($A∩B) === count($this->A) && empty($A∖B);
    }

Usage Example

 /**
  * @dataProvider dataProviderForIsNotSubset
  */
 public function testIsNotSubset(array $A, array $B)
 {
     $setA = new Set($A);
     $setB = new Set($B);
     $this->assertFalse($setA->isSubset($setB));
 }