/** @test */ public function should_see_if_array_contains_value() { $this->assertTrue(Arr::create([1, 2, 3])->contains(1)); $this->assertFalse(Arr::create([1, 2, 3])->contains(4)); $this->assertTrue(Arr::create(['hello' => 'world'])->contains('hello', 'world')); $this->assertFalse(Arr::create(['hello' => 'world'])->contains('yo', 'dawg')); }
/** * Assert the value is valid for the expectation * * @param mixed $value * @param array $options * @return bool */ public static function assert($value, array $options = []) { $locales = intlcal_get_available_locales(); if (Arr::create($locales)->contains($value)) { return true; } throw new AssertionException(sprintf('%s is not a locale', $value)); }
/** * Assert the value is valid for the expectation * * @param mixed $value * @param array $options * @return bool */ public static function assert($value, array $options = []) { $currencies = json_decode(file_get_contents(sprintf('%s%s', __DIR__, self::$path)), true); $attribute = Arr::pluck($options, 'attribute', 'name'); if (Arr::create($currencies)->contains($attribute, $value)) { return true; } throw new AssertionException(sprintf('%s is not a currency', $value)); }