DrewM\Morse\Morse::getFirstAvailable PHP 메소드

getFirstAvailable() 공개 정적인 메소드

Tests an array of feature identifiers, stopping and returnig the first that tests true.
public static getFirstAvailable ( array $featureIDs = [] ) : string
$featureIDs array Array of feature ID strings. If associative, the value is the ID, and the key is returned.
리턴 string Returns the first feature ID that tests true.
    public static function getFirstAvailable(array $featureIDs = array())
    {
        if (is_array($featureIDs) && count($featureIDs)) {
            foreach ($featureIDs as $featureID) {
                if (self::featureExists($featureID)) {
                    $parts = explode('/', $featureID);
                    return $parts[1];
                }
            }
        }
        return null;
    }

Usage Example

예제 #1
0
파일: MorseTest.php 프로젝트: drewm/morse
 public function testGetFirstAvailable()
 {
     $this->assertEquals(Morse::getFirstAvailable(array('image/fake-negative', 'image/fake-negative', 'image/fake-positive')), 'fake-positive');
     $this->assertEquals(Morse::getFirstAvailable(array('db/fake-positive', 'db/fake-negative')), 'fake-positive');
     $this->assertSame(Morse::getFirstAvailable(array('text/fake-negative')), null);
 }