protected function dependencyIsValid(
        string $asset,
        string $dependency,
        array $original,
        array $assets
    ): bool {
        // Determine if asset and dependency is circular.
        $isCircular = function ($asset, $dependency, $assets) {
            return isset($assets[$dependency]) && \in_array($asset, $assets[$dependency]['dependencies']);
        };

        if (! isset($original[$dependency])) {
            return false;
        } elseif ($dependency === $asset) {
            throw new RuntimeException("Asset [$asset] is dependent on itself.");
        } elseif ($isCircular($asset, $dependency, $assets)) {
            throw new RuntimeException("Assets [$asset] and [$dependency] have a circular dependency.");
        }

        return true;
    }