public function test_isValidComparableDate() { $this->assertFalse($this->validator->isValidComparableDate('invalid', 1)); $this->assertFalse($this->validator->isValidComparableDate('', 12)); $this->assertFalse($this->validator->isValidComparableDate('day', 88)); $this->assertTrue($this->validator->isValidComparableDate('day', 1)); $this->assertTrue($this->validator->isValidComparableDate('month', 12)); }
private function shouldBeProcessed($alert, $idSite) { if (empty($alert['id_sites']) || !in_array($idSite, $alert['id_sites'])) { return false; } $validator = new Validator(); if (!$validator->isValidComparableDate($alert['period'], $alert['compared_to'])) { // actually it would be nice to log or send a notification or whatever that we have skipped an alert return false; } if (!$this->reportExists($idSite, $alert['report'], $alert['metric'])) { // actually it would be nice to log or send a notification or whatever that we have skipped an alert return false; } return true; }