<commit_before><?php
namespace Ibsciss\Silex;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Zend\Soap;

class ZendSoapServiceProvider implements ServiceProviderInterface
{
    public function register(Application $app)
    {
        //define options
        $app['soap.wsdl'] = (isset($app['soap.wsdl'])) ? $app['soap.wsdl'] : null;
        $app['soap.dotNet'] = (isset($app['soap.dotNet'])) ? $app['soap.dotNet'] : false;
        $app['soap.server.class'] = (isset($app['soap.server.class'])) ? $app['soap.server.class'] : '\Zend\Soap\Server';
        $app['soap.client.class'] = $app->share(function($app){
            return ($app['soap.dotNet']) ? '\Zend\Soap\Client\DotNet' : '\Zend\Soap\Client';
        });
        
        
        $app['soap.clients'] = $app->share(function($app){
            return $app['soap.instances.container']['clients'];
        });
        
        $app['soap.servers'] = $app->share(function($app){
            return $app['soap.instances.container']['servers'];
        });
        
        $app['soap.client'] = $app['zend_soap.client'] = $app->share(function($app){
            $clients = $app['soap.instances.container']['clients'];
            return $clients[$app['soap.instances.default']];
        });
        
        $app['soap.server'] = $app['zend_soap.server'] = $app->share(function($app){
            $servers = $app['soap.instances.container']['servers'];
            return $servers[$app['soap.instances.default']];
        });
        
        $app['soap.instances.container'] = $app->share(function($app){
            
            $container_server = new \Pimple();
            $container_client = new \Pimple();
            
            if(!isset($app['soap.instances'])){
                $app['soap.instances'] = array('default');
            }
            
            foreach($app['soap.instances'] as $name => $value){
                
                $name = (is_array($value)) ? $name : $value;
                $wsdl = (isset($value['wsdl'])) ? $value['wsdl'] : $app['soap.wsdl'];
                
                $container_client[$name] = $container_client->share(function() use ($wsdl, $app, $value){
                    $defaultClass = (isset($value['dotNet']) && $value['dotNet']) ? '\Zend\Soap\Client\DotNet' : $app['soap.client.class'];
                    $class = (isset($value['client.class'])) ? $value['client.class'] : $defaultClass;
                    return new $class($wsdl);
                });
                
                $container_server[$name] = $container_server->share(function() use ($wsdl, $app, $value){
                    $class = (isset($value['server.class'])) ? $value['server.class'] : $app['soap.server.class'];
                    return new $class($wsdl);<commit_msg>[FIX] compatibility with php53 isset on string offset<commit_after><?php
namespace Ibsciss\Silex;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Zend\Soap;

class ZendSoapServiceProvider implements ServiceProviderInterface
{
    public function register(Application $app)
    {
        //define options
        $app['soap.wsdl'] = (isset($app['soap.wsdl'])) ? $app['soap.wsdl'] : null;
        $app['soap.dotNet'] = (isset($app['soap.dotNet'])) ? $app['soap.dotNet'] : false;
        $app['soap.server.class'] = (isset($app['soap.server.class'])) ? $app['soap.server.class'] : '\Zend\Soap\Server';
        $app['soap.client.class'] = $app->share(function($app){
            return ($app['soap.dotNet']) ? '\Zend\Soap\Client\DotNet' : '\Zend\Soap\Client';
        });
        
        
        $app['soap.clients'] = $app->share(function($app){
            return $app['soap.instances.container']['clients'];
        });
        
        $app['soap.servers'] = $app->share(function($app){
            return $app['soap.instances.container']['servers'];
        });
        
        $app['soap.client'] = $app['zend_soap.client'] = $app->share(function($app){
            $clients = $app['soap.instances.container']['clients'];
            return $clients[$app['soap.instances.default']];
        });
        
        $app['soap.server'] = $app['zend_soap.server'] = $app->share(function($app){
            $servers = $app['soap.instances.container']['servers'];
            return $servers[$app['soap.instances.default']];
        });
        
        $app['soap.instances.container'] = $app->share(function($app){
            
            $container_server = new \Pimple();
            $container_client = new \Pimple();
            
            if(!isset($app['soap.instances'])){
                $app['soap.instances'] = array('default');
            }
            
            foreach($app['soap.instances'] as $name => $value){
                
                //php5.3 compatibility, see php.net/manual/en/function.isset.php#refsect1-function.isset-examples "isset on string offset"
                if(!is_array($value)){
                    $name = $value;
                    $value = array();
                }
                
                $wsdl = (isset($value['wsdl'])) ? $value['wsdl'] : $app['soap.wsdl'];
                
                $container_client[$name] = $container_client->share(function() use ($wsdl, $app, $value){
                    $defaultClass = (isset($value['dotNet']) && $value['dotNet']) ? '\Zend\Soap\Client\DotNet' : $app['soap.client.class'];
                    $class = (isset($value['client.class'])) ? $value['client.class'] : $defaultClass;
                    return new $class($wsdl);
                });
                
                $container_server[$name] = $container_server->share(function() use ($wsdl, $app, $value){
                    $class = (isset($value['server.class'])) ? $value['server.class'] : $app['soap.server.class'];
                    return new $class($wsdl);
{'fraction_non_alphanumeric': 0.1904517453798768, 'fraction_numerical': 0.0008555783709787816, 'mean_word_length': 2.1939890710382515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6336414', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1694, 'n_words': 241}