src/MultiLanguageWrapper/MultiLanguageFallbackGenerator.php
public function create(
        Closure $performRequest,
        string $returnTypeClass,
        array $languages,
        bool $merge = false
    ) {
        $languageIdx = 0;
        $returnValue = null;
        $langLength  = sizeof($languages);
        do {
            $result = $performRequest($languages[$languageIdx]);
            $languageIdx++;
            if ($languageIdx > 0 && $merge) {
                $returnValue = $this->validator->merge($returnTypeClass, $returnValue, $result);
            } else {
                $returnValue = $result;
            }
        } while ($this->validator->isValid($returnTypeClass, $result) === false && $languageIdx < $langLength);
        return $returnValue;
    }
public function create(
        Closure $performRequest,
        string $returnTypeClass,
        array $languages,
        bool $merge = false
    ) {
        $languageIdx = 0;
        $returnValue = null;
        $langLength  = sizeof($languages);
        do {
            $result = $performRequest($languages[$languageIdx]);
            $languageIdx++;
            if ($languageIdx > 0 && $merge) {
                $returnValue = $this->validator->merge($returnTypeClass, $returnValue, $result);
            } else {
                $returnValue = $result;
            }
        } while ($this->validator->isValid($returnTypeClass, $result) === false && $languageIdx < $langLength);
        return $returnValue;
    }
public function create ( Closure $ performRequest , string $ returnTypeClass , array $ languages , bool $ merge = false ) { $ languageIdx = 0 ; $ returnValue = null ; $ langLength = sizeof ( $ languages ) ; do { $ result = $ performRequest ( $ languages [ $ languageIdx ] ) ; $ languageIdx ++ ; if ( $ languageIdx > 0 && $ merge ) { $ returnValue = $ this -> validator -> merge ( $ returnTypeClass , $ returnValue , $ result ) ; } else { $ returnValue = $ result ; } } while ( $ this -> validator -> isValid ( $ returnTypeClass , $ result ) === false && $ languageIdx < $ langLength ) ; return $ returnValue ; }
Creates an object using the provided closure, and keeps using fallback languages while the object isn't valid.

@param Closure $performRequest  The closure that calls the API and returns an object of the provided class. The
function call must accept only one parameter: the language for the request.
@param string  $returnTypeClass The type of class instance that should be returned.
@param array   $languages       The languages that should be tried.
@param bool    $merge           Merge the results in different languages together?

@return mixed
Creates an object using the provided closure and keeps using fallback languages while the object isn t valid .