/** * @param string $identifier * @return array */ public function getPermissions($identifier) { $permissions = ['r' => false, 'w' => false]; $filePerms = array_map(function ($var) { return (int) $var; }, str_split(substr(decoct($this->sftp->fileperms($identifier)), -3, 3))); if ($this->info['userId'] === $this->sftp->fileowner($identifier)) { $permissions['r'] = ($filePerms[0] & self::READABLE) === self::READABLE; $permissions['w'] = ($filePerms[0] & self::WRITABLE) === self::WRITABLE; } if (in_array($this->sftp->filegroup($identifier), $this->info['groupIds'])) { $permissions['r'] = $permissions['r'] ?: ($filePerms[1] & self::READABLE) === self::READABLE; $permissions['w'] = $permissions['w'] ?: ($filePerms[1] & self::WRITABLE) === self::WRITABLE; } $permissions['r'] = $permissions['r'] ?: ($filePerms[2] & self::READABLE) === self::READABLE; $permissions['w'] = $permissions['w'] ?: ($filePerms[2] & self::WRITABLE) === self::WRITABLE; return $permissions; }