Code Duplication    Length = 5-11 lines in 2 locations

src/AppserverIo/Psr/Naming/InitialContext.php 2 locations

@@ 343-353 (lines=11) @@
340
        if ($contextName = $resourceIdentifier->getContextName()) {
341
            // if yes, use it as application name
342
            $connection->injectAppName($contextName);
343
        } else {
344
            // use the application context from the servlet request
345
            if ($this->getServletRequest() && $this->getServletRequest()->getContext()) {
346
                $application = $this->getServletRequest()->getContext();
347
            } else {
348
                $application = $this->getApplication();
349
            }
350
351
            // use the application name
352
            $connection->injectAppName($application->getName());
353
        }
354
355
        // finally try to lookup the bean
356
        return $this->doLookup($resourceIdentifier, $connection, $sessionId);
@@ 371-375 (lines=5) @@
368
    {
369
370
        // use the application context from the servlet request
371
        if ($this->getServletRequest() && $this->getServletRequest()->getContext()) {
372
            $application = $this->getServletRequest()->getContext();
373
        } else {
374
            $application = $this->getApplication();
375
        }
376
377
        // initialize the connection
378
        $connection = LocalConnectionFactory::createContextConnection();