public static function getContents($filePath, $lock = true)
    {
        $lockTimeout = is_int($lock) && !empty($lock) ? $lock : null;
        $lock = !empty($lock);
        $file = static::ensureFileObject($filePath);
        $unlockCallback = function ($result = null) use ($lock, $filePath) {
            if ($lock) {
                static::unlock($filePath);
            }
            if (is_object($result) && $result instanceof \Throwable) {
                throw $result;
            }
            return $result;
        };
        return static::onUnlock($filePath)->then(
            function () use (&$file, $filePath, $lock, $lockTimeout) {
                if ($lock) {
                    static::lock($filePath, $lockTimeout);
                }
                return $file->exists();
            }
        )
            ->then(function () use (&$file, $filePath) {
                return $file->getContents();
            })->then($unlockCallback, $unlockCallback);
    }
public static function getContents($filePath, $lock = true)
    {
        $lockTimeout = is_int($lock) && !empty($lock) ? $lock : null;
        $lock = !empty($lock);
        $file = static::ensureFileObject($filePath);
        $unlockCallback = function ($result = null) use ($lock, $filePath) {
            if ($lock) {
                static::unlock($filePath);
            }
            if (is_object($result) && $result instanceof \Throwable) {
                throw $result;
            }
            return $result;
        };
        return static::onUnlock($filePath)->then(
            function () use (&$file, $filePath, $lock, $lockTimeout) {
                if ($lock) {
                    static::lock($filePath, $lockTimeout);
                }
                return $file->exists();
            }
        )
            ->then(function () use (&$file, $filePath) {
                return $file->getContents();
            })->then($unlockCallback, $unlockCallback);
    }
public static function getContents ( $ filePath , $ lock = true ) { $ lockTimeout = is_int ( $ lock ) && ! empty ( $ lock ) ? $ lock : null ; $ lock = ! empty ( $ lock ) ; $ file = static :: ensureFileObject ( $ filePath ) ; $ unlockCallback = function ( $ result = null ) use ( $ lock , $ filePath ) { if ( $ lock ) { static :: unlock ( $ filePath ) ; } if ( is_object ( $ result ) && $ result instanceof \ Throwable ) { throw $ result ; } return $ result ; } ; return static :: onUnlock ( $ filePath ) -> then ( function ( ) use ( & $ file , $ filePath , $ lock , $ lockTimeout ) { if ( $ lock ) { static :: lock ( $ filePath , $ lockTimeout ) ; } return $ file -> exists ( ) ; } ) -> then ( function ( ) use ( & $ file , $ filePath ) { return $ file -> getContents ( ) ; } ) -> then ( $ unlockCallback , $ unlockCallback ) ; }
Get file contents
@param string|File $filePath
@param bool|int    $lock Lock file for operation OR lock timeout
@return ExtendedPromiseInterface
Get file contents