hasKey('Credentials')) { throw new \InvalidArgumentException('Result contains no credentials'); } $c = $result['Credentials']; return new Credentials( $c['AccessKeyId'], $c['SecretAccessKey'], isset($c['SessionToken']) ? $c['SessionToken'] : null, isset($c['Expiration']) && $c['Expiration'] instanceof \DateTimeInterface ? (int) $c['Expiration']->format('U') : null ); } }