<?php

/*
 * This file is part of the FuelPHP Doctrine package.
 *
 * (c) Indigo Development Team
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Fuel\Doctrine\Providers;

use Fuel\Common\Arr;
use League\Container\ServiceProvider;
use Doctrine\Common\Cache\Cache;

/**
 * Provides Doctrine service
 *
 * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
 */
class FuelServiceProvider extends ServiceProvider
{
	/**
	 * @var array
	 */
	public $provides = [
		'doctrine.manager',
		'doctrine.metadata.php',
		'doctrine.metadata.xml',
		'doctrine.metadata.simplified_xml',
		'doctrine.metadata.yml',
		'doctrine.metadata.simplified_yml',
		'doctrine.cache.array',
		'doctrine.cache.apc',
		'doctrine.cache.xcache',
		'doctrine.cache.wincache',
		'doctrine.cache.zend',
		'doctrine.behavior.blameable',
		'doctrine.behavior.iptraceable',
		'doctrine.behavior.loggable',
		'doctrine.behavior.sluggable',
		'doctrine.behavior.soft_deletable',
		'doctrine.behavior.sortable',
		'doctrine.behavior.timestampable',
		'doctrine.behavior.translatable',
		'doctrine.behavior.tree',
		'doctrine.behavior.uploadable',
	];

	/**
	 * Default configuration values
	 *
	 * @var []
	 */
	protected $defaultConfig = [];

	/**
	 * Initializes doctrine
	 */
	private function initDoctrine()
	{
		$app = $this->getApp();

		$config = $app->getConfig();

		$config->load('doctrine', true);

		$this->defaultConfig = Arr::filterKeys($config->get('doctrine', []), ['managers', 'types'], true);
	}

	/**
	 * {@inheritdoc}
	 */
	public function register()
	{
		$this->initDoctrine();

		$this->register('doctrine.manager', function($context, array $config = [])
		{
			if ($context->isMultiton())
			{
				$instance = $context->getName() ?: '__default__';
			}
			else
			{
				$instance = '__default__';
			}

			$app = $this->getApp();
			$conf = $app->getConfig();

			$config = array_merge($this->defaultConfig, $conf->get('doctrine.managers.'.$instance, []), $config);

			return $context->resolve('Fuel\\Doctrine\\Manager', [$config]);
		});

		$this->register('doctrine.metadata.php', function($dic, $paths = [])
		{
			return $dic->resolve('Doctrine\\ORM\\Mapping\\Driver\\PHPDriver', [$paths]);
		});

		$this->register('doctrine.metadata.xml', function($dic, $paths = [])
		{
			return $dic->resolve('Doctrine\\ORM\\Mapping\\Driver\\XmlDriver', [$paths]);
		});

		$this->register('doctrine.metadata.simplified_xml', function($dic, $paths = [])
		{
			return $dic->resolve('Doctrine\\ORM\\Mapping\\Driver\\SimplifiedXmlDriver', [$paths]);
		});

		$this->register('doctrine.metadata.yml', function($dic, $paths = [])
		{
			return $dic->resolve('Doctrine\\ORM\\Mapping\\Driver\\YamlDriver', [$paths]);
		});

		$this->register('doctrine.metadata.simplified_yml', function($dic, $paths = [])
		{
			return $dic->resolve('Doctrine\\ORM\\Mapping\\Driver\\SimplifiedYamlDriver', [$paths]);
		});

		$this->register('doctrine.cache.array', 'Doctrine\\Common\\Cache\\ArrayCache');
		$this->register('doctrine.cache.apc', 'Doctrine\\Common\\Cache\\ApcCache');
		$this->register('doctrine.cache.xcache', 'Doctrine\\Common\\Cache\\XcacheCache');
		$this->register('doctrine.cache.wincache', 'Doctrine\\Common\\Cache\\WincacheCache');
		$this->register('doctrine.cache.zend', 'Doctrine\\Common\\Cache\\ZendDataCache');

		$this->register('doctrine.behavior.blameable', 'Gedmo\\Blameable\\BlameableListener');
		$this->register('doctrine.behavior.iptraceable', 'Gedmo\\IpTraceable\\IpTraceableListener');
		$this->register('doctrine.behavior.loggable', 'Gedmo\\Loggable\\LoggableListener');
		$this->register('doctrine.behavior.sluggable', 'Gedmo\\Sluggable\\SluggableListener');
		$this->register('doctrine.behavior.soft_deletable', 'Gedmo\\SoftDeletable\\SoftDeletableListener');
		$this->register('doctrine.behavior.sortable', 'Gedmo\\Sortable\\SortableListener');
		$this->register('doctrine.behavior.timestampable', 'Gedmo\\Timestampable\\TimestampableListener');

		$this->register('doctrine.behavior.translatable', function($dic)
		{
			$es = $dic->resolve('Gedmo\\Translatable\\TranslatableListener');
			$es->setTranslatableLocale(\Config::get('language', 'en'));
			$es->setDefaultLocale(\Config::get('language_fallback', 'en'));

			return $es;
		});

		$this->register('doctrine.behavior.tree', 'Gedmo\\Tree\\TreeListener');
		$this->register('doctrine.behavior.uploadable', 'Gedmo\\Uploadable\\UploadableListener');
	}

	/**
	 * Returns the current application
	 *
	 * @return \Fuel\Foundation\Application
	 */
	private function getApp()
	{
		$stack = $this->resolve('requeststack');

		if ($request = $stack->top())
		{
			$app = $request->getApplication();
		}
		else
		{
			$app = $this->resolve('application::__main');
		}

		return $app;
	}
}


<?php
/**
 * @link http://psesd.org/
 *
 * @copyright Copyright (c) 2015 Puget Sound ESD
 * @license http://psesd.org/license/
 */

namespace cascade\models;

use Yii;

/**
 * KeyTranslation is the model class for table "key_translation".
 *
 * @property string $id
 * @property string $data_interface_id
 * @property string $registry_id
 * @property string $key
 * @property string $created
 * @property string $modified
 * @property Registry $registry
 * @property DataInterface $dataInterface
 *
 * @author Jacob Morrison <email@ofjacob.com>
 */
class KeyTranslation extends \cascade\components\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function isAccessControlled()
    {
        return false;
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'key_translation';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['key'], 'required'],
            [['created', 'modified'], 'safe'],
            [['data_interface_id', 'registry_id'], 'string', 'max' => 36],
            [['key'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'data_interface_id' => 'Data Interface ID',
            'registry_id' => 'Registry ID',
            'key' => 'Key',
            'created' => 'Created',
            'modified' => 'Modified',
        ];
    }

    /**
     * Get object.
     *
     * @param boolean $checkAccess [[@doctodo param_description:checkAccess]] [optional]
     *
     * @return [[@doctodo return_type:getObject]] [[@doctodo return_description:getObject]]
     */
    public function getObject($checkAccess = true)
    {
        $registryClass = Yii::$app->classes['Registry'];

        $return = $registryClass::getObject($this->registry_id, $checkAccess);

        if (get_class($return) === 'cascade\models\Registry') {
            \d($this->registry_id);
            //throw new \Exception("TRANSLATION WHATTTT AGAIN?!");
            exit;
        }

        return $return;
    }

    /**
     * Get registry.
     *
     * @return \yii\db\ActiveRelation
     */
    public function getRegistry()
    {
        return $this->hasOne(Registry::className(), ['id' => 'registry_id']);
    }

    /**
     * Get data interface.
     *
     * @return \yii\db\ActiveRelation
     */
    public function getDataInterface()
    {
        return $this->hasOne(DataInterface::className(), ['id' => 'data_interface_id']);
    }
}


<?php
/**
 * com.xcitestudios.Generic
 *
 * @copyright Wade Womersley (xcitestudios)
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 * @link https://xcitestudios.com/
 */

namespace com\xcitestudios\Generic\Data\KeyValueStorage;

use com\xcitestudios\Generic\Data\KeyValueStorage\Interfaces\CountableIterableStorageInterface;
use com\xcitestudios\Generic\Data\KeyValueStorage\Exceptions\NotFoundException;
use Interop\Container\Exception\ContainerException;

/**
 * Simple storage for objects in a local in-memory key store.
 *
 * @package com.xcitestudios.Generic
 * @subpackage Data.KeyValueStorage
 */
class ArrayStore implements CountableIterableStorageInterface
{
    /**
     * @var array
     */
    protected $objects = [];

    /**
     * Finds an entry of the container by its identifier and returns it.
     *
     * @param string $id Identifier of the entry to look for.
     *
     * @throws NotFoundException  No entry was found for this identifier.
     * @throws ContainerException Error while retrieving the entry.
     *
     * @return mixed Entry.
     */
    public function get($id)
    {
        if (!$this->has($id)) {
            throw new NotFoundException(sprintf('%s not found in %s', $id, __CLASS__));
        }

        return $this->objects[$id];
    }

    /**
     * Returns true if the container can return an entry for the given identifier.
     * Returns false otherwise.
     *
     * @param string $id Identifier of the entry to look for.
     *
     * @return boolean
     */
    public function has($id)
    {
        return array_key_exists($id, $this->objects);
    }

    /**
     * Store an object.
     *
     * @param string $id    Identifier of the entry to save under.
     * @param mixed  $event
     */
    public function set($id, $event)
    {
        $this->objects[$id] = $event;
    }

    /**
     * Remove an object.
     *
     * @param string $id Identifier of the entry to look for.
     *
     * @throws NotFoundException
     */
    public function remove($id)
    {
        if (!$this->has($id)) {
            throw new NotFoundException(sprintf('%s not found in %s', $id, __CLASS__));
        }

        unset($this->objects[$id]);
    }

    /**
     * (PHP 5 >= 5.0.0)

     * Return the current element
     * @link http://php.net/manual/en/iterator.current.php
     * @return mixed
     */
    public function current()
    {
        return current($this->objects);
    }

    /**
     * (PHP 5 >= 5.0.0)

     * Move forward to next element
     * @link http://php.net/manual/en/iterator.next.php
     * @return void Any returned value is ignored.
     */
    public function next()
    {
        next($this->objects);
    }

    /**
     * (PHP 5 >= 5.0.0)

     * Return the key of the current element
     * @link http://php.net/manual/en/iterator.key.php
     * @return mixed scalar on success, or null on failure.
     */
    public function key()
    {
        return key($this->objects);
    }

    /**
     * (PHP 5 >= 5.0.0)

     * Checks if current position is valid
     * @link http://php.net/manual/en/iterator.valid.php
     * @return boolean The return value will be casted to boolean and then evaluated.
     * Returns true on success or false on failure.
     */
    public function valid()
    {
        return key($this->objects) !== null;
    }

    /**
     * (PHP 5 >= 5.0.0)

     * Rewind the Iterator to the first element
     * @link http://php.net/manual/en/iterator.rewind.php
     * @return void Any returned value is ignored.
     */
    public function rewind()
    {
        reset($this->objects);
    }

    /**
     * (PHP 5 >= 5.1.0)

     * Count elements of an object
     * @link http://php.net/manual/en/countable.count.php
     * @return int The custom count as an integer.
     *

     *

     * The return value is cast to an integer.
     */
    public function count()
    {
        return count($this->objects);
    }
}


<?php
namespace AuthModule\Adapter;

use AuthModule\Exception\ExceptionInterface;
use AuthModule\Identity\ModelInterface;
use AuthModule\Identity\ObjectInterface;
use Zend\Authentication\Adapter\AdapterInterface;
use Zend\Authentication\Adapter\ValidatableAdapterInterface;
use Zend\Authentication\Result;

/**
 * Class ModelAdapter
 */
class ModelAdapter implements AdapterInterface, ValidatableAdapterInterface
{
    /**
     * @var mixed
     */
    protected $identity;

    /**
     * @var mixed
     */
    protected $credential;

    /**
     * @var ModelInterface
     */
    protected $model;

    /**
     * Ctor
     *
     * @param ModelInterface $model
     */
    public function __construct(ModelInterface $model)
    {
        $this->model = $model;
    }

    /**
     * Returns the identity of the account being authenticated, or
     * NULL if none is set.
     *
     * @return mixed
     */
    public function getIdentity()
    {
        return $this->identity;
    }

    /**
     * Sets the identity for binding
     *
     * @param  mixed $identity
     * @return $this
    */
    public function setIdentity($identity)
    {
        $this->identity = $identity;
        return $this;
    }

    /**
     * Returns the credential of the account being authenticated, or
     * NULL if none is set.
     *
     * @return mixed
    */
    public function getCredential()
    {
        return $this->credential;
    }

    /**
     * Sets the credential for binding
     *
     * @param  mixed $credential
     * @return $this
    */
    public function setCredential($credential)
    {
        $this->credential = $credential;
        return $this;
    }

    /**
     * Performs an authentication attempt
     *
     * @throws ExceptionInterface If authentication cannot be performed
     * @return Result
     */
    public function authenticate()
    {
        $identity = $this->getIdentity();
        $results = $this->model->findByIdentity($identity);

        $identityObject = null;
        $count = 0;
        foreach ($results as $identityObject) {
            if ($count > 1) {
                return new Result(
                    Result::FAILURE_IDENTITY_AMBIGUOUS,
                    $identity,
                    ['More than one record matches the supplied identity.']
                );
            }
            $count++;
        }

        if ($count == 0) {
            return new Result(
                Result::FAILURE_IDENTITY_NOT_FOUND,
                $identity,
                ['A record with the supplied identity could not be found.']
            );
        }

        if ($identityObject instanceof ObjectInterface) {
            if ($identityObject->validateCredential($this->getCredential())) {
                return new Result(Result::SUCCESS, $identity);
            } // else
            return new Result(
                Result::FAILURE_CREDENTIAL_INVALID,
                $identity,
                ['wrong password']
            );
        }

        return new Result(
            Result::FAILURE_UNCATEGORIZED,
            $identity,
            ['generic error']
        );
    }

    /**
     * @param $identity
     * @return ObjectInterface|null
     */
    public function getIdentityObjectByIdentity($identity)
    {
        if (!empty($identity)) {
            $results = $this->model->findByIdentity($identity);
            $objIdentity = $results->current(); // FIXME: strong assumption: try current($results)
            if ($objIdentity instanceof ObjectInterface) {
                return $objIdentity;
            }
        }
        return null;
    }
}


<?php

/*
 * This file is part of the Predis package.
 *
 * (c) Daniele Alessandri <suppakilla@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Predis\Command\Redis;

use Predis\Command\Command as RedisCommand;

/**
 * @link http://redis.io/commands/zrange
 *
 * @author Daniele Alessandri <suppakilla@gmail.com>
 */
class ZRANGE extends RedisCommand
{
    /**
     * {@inheritdoc}
     */
    public function getId()
    {
        return 'ZRANGE';
    }

    /**
     * {@inheritdoc}
     */
    public function setArguments(array $arguments)
    {
        if (count($arguments) === 4) {
            $lastType = gettype($arguments[3]);

            if ($lastType === 'string' && strtoupper($arguments[3]) === 'WITHSCORES') {
                // Used for compatibility with older versions
                $arguments[3] = array('WITHSCORES' => true);
                $lastType = 'array';
            }

            if ($lastType === 'array') {
                $options = $this->prepareOptions(array_pop($arguments));
                $arguments = array_merge($arguments, $options);
            }
        }

        parent::setArguments($arguments);
    }

    /**
     * Returns a list of options and modifiers compatible with Redis.
     *
     * @param array $options List of options.
     *
     * @return array
     */
    protected function prepareOptions($options)
    {
        $opts = array_change_key_case($options, CASE_UPPER);
        $finalizedOpts = array();

        if (!empty($opts['WITHSCORES'])) {
            $finalizedOpts[] = 'WITHSCORES';
        }

        return $finalizedOpts;
    }

    /**
     * Checks for the presence of the WITHSCORES modifier.
     *
     * @return bool
     */
    protected function withScores()
    {
        $arguments = $this->getArguments();

        if (count($arguments) < 4) {
            return false;
        }

        return strtoupper($arguments[3]) === 'WITHSCORES';
    }

    /**
     * {@inheritdoc}
     */
    public function parseResponse($data)
    {
        if ($this->withScores()) {
            $result = array();

            for ($i = 0; $i < count($data); ++$i) {
                $result[$data[$i]] = $data[++$i];
            }

            return $result;
        }

        return $data;
    }
}


<?php

namespace Monolyth\Disclosure;

use ReflectionFunction;
use ReflectionClass;
use Psr\Container\Exception\NotFoundExceptionInterface;

/**
 * Injector trait classes with dependencies can "use".
 */
trait Injector
{
    /**
     * Inject the specified dependencies into this object. Each argument can be
     * either a string containing the name of the dependency, or a callable
     * where each argument defines that name.
     *
     * @param string|callable ...$injects What to inject.
     * @return void
     * @throws Psr\Container\Exception\NotFoundExceptionInterface if _any_ of
     *  the requested dependencies could not be resolved.
     */
    public function inject(...$injects) : void
    {
        $container = new Container;
        $requested = [];
        foreach ($injects as $inject) {
            if (is_string($inject)) {
                $requested[] = $inject;
            } elseif (is_callable($inject)) {
                $reflection = new ReflectionFunction($inject);
                foreach ($reflection->getParameters() as $param) {
                    $requested[] = $param->name;
                }
            }
        }
        foreach ($requested as $dependency) {
            $this->$dependency = $container->get($dependency);
        }
    }

    /**
     * For classes that expect dependencies in their constructor, you can use
     * this method instead of "new" with lots of Container::get calls.
     *
     * Type-hinted arguments _must_ match a dependency. If no dependency exists,
     * a new instance will be passed.
     *
     * @return object An object of the same class as called on, with dependencies
     *  injected through its constructor.
     * @throws Disclosure\TypeMismatchException if the retrieved dependency does
     *  not satisfy the argument's type hint.
     * @throws Psr\Container\Exception\NotFoundExceptionInterface if _any_ of
     *  the requested dependencies could not be resolved.
     */
    public static function resolve() : object
    {
        $reflection = new ReflectionClass(__CLASS__);
        $constructor = $reflection->getConstructor();
        $args = [];
        $container = new Container;
        foreach ($constructor->getParameters() as $parameter) {
            $name = $parameter->name;
            $e = $inject = $class = null;
            try {
                $inject = $container->get($name);
            } catch (NotFoundExceptionInterface $e) {
            }
            if ($class = $parameter->getClass()) {
                $instance = $class->getName();
                if (isset($inject)) {
                    if ($inject instanceof $instance) {
                        $args[] = $inject;
                        continue;
                    } else {
                        throw new TypeMismatchException(get_class($inject));
                    }
                }
                if ($class->implementsInterface(
                    'Monolyth\Disclosure\Injectable'
                )) {
                    $args[] = $class::resolve();
                } else {
                    $args[] = $class->newInstance();
                }
            } elseif ($parameter->isDefaultValueAvailable()) {
                $args[] = $parameter->getDefaultValue();
            } elseif (isset($e)) {
                throw $e;
            } elseif (isset($inject)) {
                $args[] = $inject;
            }
        }
        return $reflection->newInstanceArgs($args);
    }
}


<?php
/**
 * Jaeger
 *
 * @copyright	Copyright (c) 2015-2016, mithra62
 * @link		http://jaeger-app.com
 * @version		1.0
 * @filesource 	./Db.php
 */
namespace JaegerApp;

use JaegerApp\Exceptions\DbException;

/**
 * Jaeger - Database Object
 *
 * Wrapper for a simple database interface
 *
 * @package Database
 * @author Eric Lamb <eric@mithra62.com>
 */
class Db
{
    /**
     * The external db object
     *
     * @var Db\DbInterface
     */
    protected $db = null;

    /**
     * The database connection details
     *
     * @var array
     */
    protected $credentials = array();

    /**
     * The columns we want
     *
     * @var array
     */
    protected $columns = array();

    /**
     * The WHERE for the SQL
     *
     * @var array|string
     */
    protected $where = '1=1';

    /**
     * The table name we're working with
     *
     * @var string
     */
    protected $table = false;

    /**
     * How we want to access the database engine
     * mysqli is the default
     * @var string
     */
    protected $access_type = 'mysqli';

    /**
     * Sets the method of accessing the database
     * @param string $type
     * @return JaegerApp\Db
     */
    public function setAccessType($type)
    {
        $this->access_type = $type;
        return $this;
    }

    /**
     * Returns the access type for how we're interacting with the database
     * @return string
     */
    public function getAccessType()
    {
        return $this->access_type;
    }

    /**
     * Set the columns we want to return
     *
     * @param array $columns
     * @return \JaegerApp\Db
     */
    public function select(array $columns = array())
    {
        $this->columns = $columns;
        return $this;
    }

    /**
     * Sets the main table we're pulling from
     *
     * @param string $table
     * @return \JaegerApp\Db
     */
    public function from($table)
    {
        $this->table = $table;
        return $this;
    }

    /**
     * Sets the SQL WHERE
     *
     * Can be either a string or an array of key=>value pairs
     *
     * @param array $where
     * @return \JaegerApp\Db
     */
    public function where($where = array())
    {
        $this->where = $where;
        return $this;
    }

    /**
     * Returns the SQL WHERE
     *
     * @return array|string
     */
    public function getWhere()
    {
        return $this->where;
    }

    /**
     * Returns the table
     *
     * @return string
     */
    public function getTable()
    {
        return $this->table;
    }

    /**
     * Set the credentials for accessing the database
     *
     * @param array $credentials
     * @return \JaegerApp\Db
     */
    public function setCredentials(array $credentials)
    {
        $this->credentials = $credentials;
        return $this;
    }

    /**
     * Returns the credentials
     *
     * @return \JaegerApp\array
     */
    public function getCredentials()
    {
        return $this->credentials;
    }

    /**
     * Executes and performs a query
     *
     * @return array
     */
    public function get()
    {
        return $this->getDb()->select($this->getTable(), $this->getWhere())->get();
    }

    /**
     * Inserts data into the $table
     *
     * @param string $table
     * @param data $data
     * @return false|int|string false on error
     */
    public function insert($table, $data = array())
    {
        return $this->getDb()->insert($table, $data);
    }

    /**
     * Updates a table
     *
     * @param string $table
     * @param array $data
     * @param string $where
     */
    public function update($table, $data = array(), $where = '1=1')
    {
        if (! $this->getDb()->update($table, $data, $where)) {
            throw new DbException("Failed updating " . $table);
        }

        return true;
    }

    /**
     * Truncates a given table
     *
     * @param string $table
     */
    public function emptyTable($table)
    {
        return $this->getDb()->query("TRUNCATE " . $table);
    }

    /**
     * Executes a query and, optionally, returns the result
     *
     * @param string $sql
     * @param bool $return
     * @return array|void
     */
    public function query($sql, $return = false)
    {
        $query = $this->getDb()->query($sql, true);
        if ($return) {
            return $query;
        }
    }

    /**
     * Returns an instance of the database object
     *
     * @todo Update engine selection to be
     *          polymorphic instead of conditional
     * @return Db\DbInterface
     * @throws Exceptions\DbException
     */
    public function getDb()
    {
        if (is_null($this->db)) {

            //try explicit type setting
            if( $this->getAccessType() == 'mysqli' && function_exists('mysqli_select_db') ){
                $this->db = new Db\Mysqli();
            }
            else
            {
                if ( $this->getAccessType() == 'pdo' && class_exists('PDO') ){
                    $this->db = new Db\Pdo();
                }
            }

            //fuck it; we're just gonna choose one then
            if(is_null($this->db)){
                if( class_exists('PDO') ){
                    $this->db = new Db\Pdo();
                }
                elseif ( function_exists('mysqli_select_db') ) {
                    $this->db = new Db\Mysqli();
                }
                else {
                    throw new DbException('Database engine not available! Must be either PDO or mysqli');
                }
            }

            $this->db->setCredentials($this->credentials);
        }

        return $this->db;
    }

    /**
     * Returns all the available tables
     *
     * @return array
     */
    public function getTables()
    {
        $tables = $this->getDb()->getAllTables();
        $return = array();
        foreach ($tables as $name => $table) {
            foreach ($table as $key => $value) {
                $return[$table[$key]] = $table[$key];
            }
        }

        return $return;
    }

    /**
     * Returns the details for all the tables
     *
     * @return array
     */
    public function getTableStatus()
    {
        $tables = $this->getDb()->getTableStatus();
        return $tables;
    }

    /**
     * Returns the CREATE TABLE statement for the given $table
     *
     * @param string $table
     *            The name of the table to create a statement for
     * @param bool $if_not_exists
     *            If set to true, the statement will append IF NOT EXISTS
     * @return Ambigous <boolean, mixed>
     */
    public function getCreateTable($table, $if_not_exists = false)
    {
        return $this->getDb()->getCreateTable($table, $if_not_exists);
    }

    /**
     * Escapes a string for db use
     *
     * @param string $string
     * @return Ambigous <\voku\db\array, \voku\db\bool, \voku\db\float, \voku\db\int, \voku\db\string>
     */
    public function escape($string)
    {
        return $this->getDb()->escape($string);
    }

    /**
     * Changes the database to $db_name
     *
     * @param string $db_name
     *            The name of the database we want to change to
     * @return \JaegerApp\Db
     */
    public function setDbName($db_name)
    {
        $this->getDb()->setDbName($db_name);
        return $this;
    }

    /**
     * Clears any records in memory associated with a result set.
     * It allows calling with no select query having occurred.
     *
     * @access public
     */
    public function clear()
    {
        $this->getDb()->clear();
    }

    /**
     * Returns the total number of rows in a given table without filtering
     * @param string $table The name of the table
     * @return number
     */
    public function totalRows($table)
    {
        return $this->getDb()->totalRows($table);
    }

    /**
     * Returns the columns on a given table
     * @param string $table
     * @return array
     */
    public function getColumns($table)
    {
        return $this->getDb()->getColumns($table);
    }

    /**
     * Determines whether a given database exists
     * @param string $name
     * @return boolean
     */
    public function checkDbExists($name)
    {
        $data = $this->query("SELECT COUNT(*) AS total FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '".$this->escape($name)."'", true);
        if( isset($data['0']['total']) && $data['0']['total'] == '1' )
        {
            return true;
        }

        return false;
    }

}


<?php

namespace Esockets\Base;

use Esockets\Base\Exception\ConfiguratorException;
use Esockets\Base\Exception\ConnectionFactoryException;
use Esockets\Client;
use Esockets\Server;
use Esockets\Socket\SocketFactory;

final class Configurator
{
    public const CONNECTION_TYPE = 0;
    public const CONNECTION_TYPE_SOCKET = 1;
    public const CONNECTION_TYPE_CUSTOM = 7;
    public const CONNECTION_CONFIG = 5;

    public const CONNECTION_TIMEOUT = 6;
    public const PING_INTERVAL = 7;
    public const RECONNECT_INTERVAL = 8;

    public const FACTORY_CLASS = 2;
    public const PROTOCOL_CLASS = 3;
    public const ADDRESS = 4;

    private $connectionType;

    /**
     * @var AbstractConnectionFactory
     */
    private $connectionFactory;
    /**
     * @var AbstractProtocol|string
     */
    private $protocolClass;
    private $address;
    private $connectionTimeout = 60;
    private $pingInterval = 30;
    private $reconnectInterval = 5;

    /**
     * @param array $config
     *
     * @throws ConfiguratorException
     */
    public function __construct(array $config = [])
    {
        if (isset($config[self::CONNECTION_TYPE])) {
            $connectionType = $config[self::CONNECTION_TYPE];
            $connectionConfig = $config[self::CONNECTION_CONFIG] ?? [];
            switch ($connectionType) {
                case self::CONNECTION_TYPE_SOCKET:
                    $this->initSocket($connectionConfig);
                    break;
                case self::CONNECTION_TYPE_CUSTOM:
                    $this->initCustom($connectionConfig);
                    break;
                default:
                    throw new ConfiguratorException('Unknown CONNECTION_TYPE: ' . $connectionType . '.');
            }
        }
        if (isset($config[self::PROTOCOL_CLASS])) {
            $this->useProtocol($config[self::PROTOCOL_CLASS]);
        }
        if (isset($config[self::CONNECTION_TIMEOUT])) {
            $this->connectionTimeout = (int)$config[self::CONNECTION_TIMEOUT];
        }
        if (isset($config[self::PING_INTERVAL])) {
            $this->pingInterval = (int)$config[self::PING_INTERVAL];
        }
        if (isset($config[self::RECONNECT_INTERVAL])) {
            $this->reconnectInterval = (int)$config[self::RECONNECT_INTERVAL];
        }
    }

    /**
     * @param array $config
     *
     * @throws ConnectionFactoryException
     */
    private function initSocket(array $config)
    {
        $this->connectionFactory = new SocketFactory($config);
        $this->connectionType = self::CONNECTION_TYPE_SOCKET;
    }

    /**
     * @param array $config
     *
     * @throws ConfiguratorException
     * @todo пока не работоспособно!
     */
    private function initCustom(array $config)
    {
        throw new \LogicException('It\'s not working');
        //$this->connectionFactory =
        if (!class_exists($clientClass)) {
            throw new ConfiguratorException('The connection class "' . $clientClass . '" is not exists.');
        }
        if (!$clientClass instanceof IoAwareInterface) {
            if (!class_exists($clientClass)) {
                throw new ConfiguratorException('The class "' . $clientClass . '" is not a connection class.');
            }
        }
        $this->connectionType = self::CONNECTION_TYPE_CUSTOM;
        $this->clientClass = $clientClass;
    }

    /**
     * @param string $protocolClass
     *
     * @throws ConfiguratorException
     */
    public function useProtocol(string $protocolClass)
    {
        if (!is_subclass_of($protocolClass, AbstractProtocol::class)) {
            throw new ConfiguratorException('Unknown protocol class: ' . $protocolClass . '.');
        }
        if (!class_exists($protocolClass)) {
            throw new ConfiguratorException('The protocol class "' . $protocolClass . '" is not exists.');
        }
        $this->protocolClass = $protocolClass;
    }

    public function connectToAddress(AbstractAddress $address): self
    {
        $this->address = $address;
        return $this;
    }

    /**s
     *
     * @return Client
     */
    public function makeClient(): Client
    {
        $client = $this->connectionFactory->makeClient();
        return new Client(
            $client,
            $this->protocolClass::create($client),
            $this->connectionTimeout,
            $this->pingInterval,
            $this->reconnectInterval
        );
    }

    public function makeServer(): Server
    {
        return new Server(
            $this->connectionFactory->makeServer(),
            $this
        );
    }

    public function makePeer(AbstractConnectionResource $connectionResource)
    {
        $peer = $this->connectionFactory->makePeer($connectionResource);
        return new Client(
            $peer,
            $this->protocolClass::create($peer),
            $this->connectionTimeout,
            $this->pingInterval,
            $this->reconnectInterval
        );
    }

    /**
     * @return AbstractAddress
     *
     * @throws ConfiguratorException
     */
    public function getAddress(): AbstractAddress
    {
        if (null === $this->address || !$this->address instanceof AbstractAddress) {
            throw new ConfiguratorException('Connection address is not configured.');
        }
        return $this->address;
    }
}


<?php
/**
 * @link http://psesd.org/
 *
 * @copyright Copyright (c) 2015 Puget Sound ESD
 * @license http://psesd.org/license/
 */

namespace cascade\components\db\behaviors;

use yii\helpers\Url;

/**
 * SearchTermResult [[@doctodo class_description:cascade\components\db\behaviors\SearchTermResult]].
 *
 * @author Jacob Morrison <email@ofjacob.com>
 */
class SearchTermResult extends \canis\db\behaviors\SearchTermResult
{
    /**
     * @var [[@doctodo var_type:_icon]] [[@doctodo var_description:_icon]]
     */
    protected $_icon;
    /**
     * @var [[@doctodo var_type:_objectType]] [[@doctodo var_description:_objectType]]
     */
    protected $_objectType;
    /**
     * @var [[@doctodo var_type:_objectTypeDescriptor]] [[@doctodo var_description:_objectTypeDescriptor]]
     */
    protected $_objectTypeDescriptor;
    /**
     * @var [[@doctodo var_type:_url]] [[@doctodo var_description:_url]]
     */
    protected $_url;

    /**
     * Set url.
     *
     * @param [[@doctodo param_type:value]] $value [[@doctodo param_description:value]]
     */
    public function setUrl($value)
    {
        $this->_url = $value;
    }

    /**
     * Get url.
     *
     * @return [[@doctodo return_type:getUrl]] [[@doctodo return_description:getUrl]]
     */
    public function getUrl()
    {
        if (is_null($this->_url) && isset($this->object)) {
            $this->_url = Url::to($this->object->getUrl('view', [], false));
        }

        return $this->_url;
    }

    /**
     * Get icon.
     *
     * @return [[@doctodo return_type:getIcon]] [[@doctodo return_description:getIcon]]
     */
    public function getIcon()
    {
        if (is_null($this->_icon) && isset($this->object)) {
            $this->_icon = ['class' => $this->object->objectType->icon, 'title' => $this->objectTypeDescriptor];
        }

        return $this->_icon;
    }

    /**
     * Set icon.
     *
     * @param [[@doctodo param_type:icon]] $icon [[@doctodo param_description:icon]]
     */
    public function setIcon($icon)
    {
        if (is_string($icon)) {
            $icon = ['class' => $icon];
        }
        $this->_icon = $icon;
    }

    /**
     * Get object type descriptor.
     *
     * @return [[@doctodo return_type:getObjectTypeDescriptor]] [[@doctodo return_description:getObjectTypeDescriptor]]
     */
    public function getObjectTypeDescriptor()
    {
        if (is_null($this->_objectTypeDescriptor) && isset($this->object)) {
            $this->_objectTypeDescriptor = $this->object->objectType->title->upperSingular;
        }

        return $this->_objectTypeDescriptor;
    }

    /**
     * Set object type descriptor.
     *
     * @param [[@doctodo param_type:type]] $type [[@doctodo param_description:type]]
     */
    public function setObjectTypeDescriptor($type)
    {
        $this->_objectTypeDescriptor = $type;
    }

    /**
     * Get object type.
     *
     * @return [[@doctodo return_type:getObjectType]] [[@doctodo return_description:getObjectType]]
     */
    public function getObjectType()
    {
        if (is_null($this->_objectType) && isset($this->object)) {
            $this->_objectType = $this->object->objectType->systemId;
        }

        return $this->_objectType;
    }

    /**
     * Set object type.
     *
     * @param [[@doctodo param_type:type]] $type [[@doctodo param_description:type]]
     */
    public function setObjectType($type)
    {
        $this->_objectType = $type;
    }

    /**
     * @inheritdoc
     */
    public function toArray()
    {
        return array_merge(parent::toArray(), [
            'icon' => $this->icon,
            'url' => $this->url,
            'objectType' => $this->objectType,
        ]);
    }

    /**
     * @inheritdoc
     */
    public function getScore()
    {
        if (empty($this->object->objectType->searchWeight)) {
            return 0;
        }

        return parent::getScore() * $this->object->objectType->searchWeight;
    }
}


<?php
namespace Poirot\Queue\Worker;

use Poirot\Events\Event;
use Poirot\Events\EventHeap;
use Poirot\Queue\Interfaces\iPayloadQueued;

class EventHeapOfWorker
    extends EventHeap
{
    const EVENT_PAYLOAD_RECEIVED = 'worker.payload.received';
    const EVENT_PAYLOAD_FAILURE  = 'worker.max.retries.exceeded';
    const EVENT_PAYLOAD_SUCCEED  = 'worker.after.successful.exec';
    const EVENT_PAYLOAD_ERROR    = 'worker.perform.fail';

    /**
     * Initialize
     *
     */
    function __init()
    {
        $this->collector = new DataCollector;

        // attach default event names:
        $this->bind(new Event(self::EVENT_PAYLOAD_RECEIVED));
        $this->bind(new Event(self::EVENT_PAYLOAD_FAILURE));
        $this->bind(new Event(self::EVENT_PAYLOAD_SUCCEED));
        $this->bind(new Event(self::EVENT_PAYLOAD_ERROR));
    }

    /**
     * @override ide auto info
     * @inheritdoc
     *
     * @return DataCollector
     */
    function collector($options = null)
    {
        return parent::collector($options);
    }
}

class DataCollector
    extends \Poirot\Events\Event\DataCollector
{
    /** @var iPayloadQueued */
    protected $payload;

    /**
     * @return mixed
     */
    public function getPayload()
    {
        return $this->payload;
    }

    /**
     * @param mixed $payload
     */
    public function setPayload($payload)
    {
        $this->payload = $payload;
    }
}


<?php

namespace interactivesolutions\honeycomblanguages\database\seeds;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use interactivesolutions\honeycomblanguages\app\models\HCLanguages;
use League\Flysystem\Exception;

class LanguagesSeeder extends Seeder
{
    /**
     * Run the database seeds.
     * @return void
     * @throws Exception
     */
    public function run()
    {
        $list = [
            ["language_family" => "Northwest Caucasian", "language" => "Abkhaz", "native_name" => "аҧсуа бызшәа, аҧсшәа", "iso_639_1" => "ab", "iso_639_2" => "abk"],
            ["language_family" => "Afro-Asiatic", "language" => "Afar", "native_name" => "Afaraf", "iso_639_1" => "aa", "iso_639_2" => "aar"],
            ["language_family" => "Indo-European", "language" => "Afrikaans", "native_name" => "Afrikaans", "iso_639_1" => "af", "iso_639_2" => "afr"],
            ["language_family" => "Niger–Congo", "language" => "Akan", "native_name" => "Akan", "iso_639_1" => "ak", "iso_639_2" => "aka"],
            ["language_family" => "Indo-European", "language" => "Albanian", "native_name" => "gjuha shqipe", "iso_639_1" => "sq", "iso_639_2" => "sqi"],
            ["language_family" => "Afro-Asiatic", "language" => "Amharic", "native_name" => "አማርኛ", "iso_639_1" => "am", "iso_639_2" => "amh"],
            ["language_family" => "Afro-Asiatic", "language" => "Arabic", "native_name" => "العربية", "iso_639_1" => "ar", "iso_639_2" => "ara"],
            ["language_family" => "Indo-European", "language" => "Aragonese", "native_name" => "aragonés", "iso_639_1" => "an", "iso_639_2" => "arg"],
            ["language_family" => "Indo-European", "language" => "Armenian", "native_name" => "Հայերեն", "iso_639_1" => "hy", "iso_639_2" => "hye"],
            ["language_family" => "Indo-European", "language" => "Assamese", "native_name" => "অসমীয়া", "iso_639_1" => "as", "iso_639_2" => "asm"],
            ["language_family" => "Northeast Caucasian", "language" => "Avaric", "native_name" => "авар мацӀ, магӀарул мацӀ", "iso_639_1" => "av", "iso_639_2" => "ava"],
            ["language_family" => "Indo-European", "language" => "Avestan", "native_name" => "avesta", "iso_639_1" => "ae", "iso_639_2" => "ave"],
            ["language_family" => "Aymaran", "language" => "Aymara", "native_name" => "aymar aru", "iso_639_1" => "ay", "iso_639_2" => "aym"],
            ["language_family" => "Turkic", "language" => "Azerbaijani", "native_name" => "azərbaycan dili", "iso_639_1" => "az", "iso_639_2" => "aze"],
            ["language_family" => "Niger–Congo", "language" => "Bambara", "native_name" => "bamanankan", "iso_639_1" => "bm", "iso_639_2" => "bam"],
            ["language_family" => "Turkic", "language" => "Bashkir", "native_name" => "башҡорт теле", "iso_639_1" => "ba", "iso_639_2" => "bak"],
            ["language_family" => "Language isolate", "language" => "Basque", "native_name" => "euskara, euskera", "iso_639_1" => "eu", "iso_639_2" => "eus"],
            ["language_family" => "Indo-European", "language" => "Belarusian", "native_name" => "беларуская мова", "iso_639_1" => "be", "iso_639_2" => "bel"],
            ["language_family" => "Indo-European", "language" => "Bengali; Bangla", "native_name" => "বাংলা", "iso_639_1" => "bn", "iso_639_2" => "ben"],
            ["language_family" => "Indo-European", "language" => "Bihari", "native_name" => "भोजपुरी", "iso_639_1" => "bh", "iso_639_2" => "bih"],
            ["language_family" => "Creole", "language" => "Bislama", "native_name" => "Bislama", "iso_639_1" => "bi", "iso_639_2" => "bis"],
            ["language_family" => "Indo-European", "language" => "Bosnian", "native_name" => "bosanski jezik", "iso_639_1" => "bs", "iso_639_2" => "bos"],
            ["language_family" => "Indo-European", "language" => "Breton", "native_name" => "brezhoneg", "iso_639_1" => "br", "iso_639_2" => "bre"],
            ["language_family" => "Indo-European", "language" => "Bulgarian", "native_name" => "български език", "iso_639_1" => "bg", "iso_639_2" => "bul"],
            ["language_family" => "Sino-Tibetan", "language" => "Burmese", "native_name" => "ဗမာစာ", "iso_639_1" => "my", "iso_639_2" => "mya"],
            ["language_family" => "Indo-European", "language" => "Catalan; Valencian", "native_name" => "català, valencià", "iso_639_1" => "ca", "iso_639_2" => "cat"],
            ["language_family" => "Austronesian", "language" => "Chamorro", "native_name" => "Chamoru", "iso_639_1" => "ch", "iso_639_2" => "cha"],
            ["language_family" => "Northeast Caucasian", "language" => "Chechen", "native_name" => "нохчийн мотт", "iso_639_1" => "ce", "iso_639_2" => "che"],
            ["language_family" => "Niger–Congo", "language" => "Chichewa; Chewa; Nyanja", "native_name" => "chiCheŵa, chinyanja", "iso_639_1" => "ny", "iso_639_2" => "nya"],
            ["language_family" => "Sino-Tibetan", "language" => "Chinese", "native_name" => "中文 (Zhōngwén), 汉语, 漢語", "iso_639_1" => "zh", "iso_639_2" => "zho"],
            ["language_family" => "Turkic", "language" => "Chuvash", "native_name" => "чӑваш чӗлхи", "iso_639_1" => "cv", "iso_639_2" => "chv"],
            ["language_family" => "Indo-European", "language" => "Cornish", "native_name" => "Kernewek", "iso_639_1" => "kw", "iso_639_2" => "cor"],
            ["language_family" => "Indo-European", "language" => "Corsican", "native_name" => "corsu, lingua corsa", "iso_639_1" => "co", "iso_639_2" => "cos"],
            ["language_family" => "Algonquian", "language" => "Cree", "native_name" => "ᓀᐦᐃᔭᐍᐏᐣ", "iso_639_1" => "cr", "iso_639_2" => "cre"],
            ["language_family" => "Indo-European", "language" => "Croatian", "native_name" => "hrvatski jezik", "iso_639_1" => "hr", "iso_639_2" => "hrv"],
            ["language_family" => "Indo-European", "language" => "Czech", "native_name" => "čeština, český jazyk", "iso_639_1" => "cs", "iso_639_2" => "ces"],
            ["language_family" => "Indo-European", "language" => "Danish", "native_name" => "dansk", "iso_639_1" => "da", "iso_639_2" => "dan"],
            ["language_family" => "Indo-European", "language" => "Divehi; Dhivehi; Maldivian;", "native_name" => "ދިވެހި", "iso_639_1" => "dv", "iso_639_2" => "div"],
            ["language_family" => "Indo-European", "language" => "Dutch", "native_name" => "Nederlands, Vlaams", "iso_639_1" => "nl", "iso_639_2" => "nld"],
            ["language_family" => "Sino-Tibetan", "language" => "Dzongkha", "native_name" => "རྫོང་ཁ", "iso_639_1" => "dz", "iso_639_2" => "dzo"],
            ["language_family" => "Indo-European", "language" => "English", "native_name" => "English", "iso_639_1" => "en", "iso_639_2" => "eng"],
            ["language_family" => "Constructed", "language" => "Esperanto", "native_name" => "Esperanto", "iso_639_1" => "eo", "iso_639_2" => "epo"],
            ["language_family" => "Uralic", "language" => "Estonian", "native_name" => "eesti, eesti keel", "iso_639_1" => "et", "iso_639_2" => "est"],
            ["language_family" => "Niger–Congo", "language" => "Ewe", "native_name" => "Eʋegbe", "iso_639_1" => "ee", "iso_639_2" => "ewe"],
            ["language_family" => "Indo-European", "language" => "Faroese", "native_name" => "føroyskt", "iso_639_1" => "fo", "iso_639_2" => "fao"],
            ["language_family" => "Austronesian", "language" => "Fijian", "native_name" => "vosa Vakaviti", "iso_639_1" => "fj", "iso_639_2" => "fij"],
            ["language_family" => "Uralic", "language" => "Finnish", "native_name" => "suomi, suomen kieli", "iso_639_1" => "fi", "iso_639_2" => "fin"],
            ["language_family" => "Indo-European", "language" => "French", "native_name" => "français, langue française", "iso_639_1" => "fr", "iso_639_2" => "fra"],
            ["language_family" => "Niger–Congo", "language" => "Fula; Fulah; Pulaar; Pular", "native_name" => "Fulfulde, Pulaar, Pular", "iso_639_1" => "ff", "iso_639_2" => "ful"],
            ["language_family" => "Indo-European", "language" => "Galician", "native_name" => "galego", "iso_639_1" => "gl", "iso_639_2" => "glg"],
            ["language_family" => "South Caucasian", "language" => "Georgian", "native_name" => "ქართული", "iso_639_1" => "ka", "iso_639_2" => "kat"],
            ["language_family" => "Indo-European", "language" => "German", "native_name" => "Deutsch", "iso_639_1" => "de", "iso_639_2" => "deu"],
            ["language_family" => "Indo-European", "language" => "Greek, Modern", "native_name" => "ελληνικά", "iso_639_1" => "el", "iso_639_2" => "ell"],
            ["language_family" => "Tupian", "language" => "Guaraní", "native_name" => "Avañe'ẽ", "iso_639_1" => "gn", "iso_639_2" => "grn"],
            ["language_family" => "Indo-European", "language" => "Gujarati", "native_name" => "ગુજરાતી", "iso_639_1" => "gu", "iso_639_2" => "guj"],
            ["language_family" => "Creole", "language" => "Haitian; Haitian Creole", "native_name" => "Kreyòl ayisyen", "iso_639_1" => "ht", "iso_639_2" => "hat"],
            ["language_family" => "Afro-Asiatic", "language" => "Hausa", "native_name" => "Hausa, هَوُسَ", "iso_639_1" => "ha", "iso_639_2" => "hau"],
            ["language_family" => "Afro-Asiatic", "language" => "Hebrew (modern)", "native_name" => "עברית", "iso_639_1" => "he", "iso_639_2" => "heb"],
            ["language_family" => "Niger–Congo", "language" => "Herero", "native_name" => "Otjiherero", "iso_639_1" => "hz", "iso_639_2" => "her"],
            ["language_family" => "Indo-European", "language" => "Hindi", "native_name" => "हिन्दी, हिंदी", "iso_639_1" => "hi", "iso_639_2" => "hin"],
            ["language_family" => "Austronesian", "language" => "Hiri Motu", "native_name" => "Hiri Motu", "iso_639_1" => "ho", "iso_639_2" => "hmo"],
            ["language_family" => "Uralic", "language" => "Hungarian", "native_name" => "magyar", "iso_639_1" => "hu", "iso_639_2" => "hun"],
            ["language_family" => "Constructed", "language" => "Interlingua", "native_name" => "Interlingua", "iso_639_1" => "ia", "iso_639_2" => "ina"],
            ["language_family" => "Austronesian", "language" => "Indonesian", "native_name" => "Bahasa Indonesia", "iso_639_1" => "id", "iso_639_2" => "ind"],
            ["language_family" => "Constructed", "language" => "Interlingue", "native_name" => "Originally called Occidental; then Interlingue after WWII", "iso_639_1" => "ie", "iso_639_2" => "ile"],
            ["language_family" => "Indo-European", "language" => "Irish", "native_name" => "Gaeilge", "iso_639_1" => "ga", "iso_639_2" => "gle"],
            ["language_family" => "Niger–Congo", "language" => "Igbo", "native_name" => "Asụsụ Igbo", "iso_639_1" => "ig", "iso_639_2" => "ibo"],
            ["language_family" => "Eskimo–Aleut", "language" => "Inupiaq", "native_name" => "Iñupiaq, Iñupiatun", "iso_639_1" => "ik", "iso_639_2" => "ipk"],
            ["language_family" => "Constructed", "language" => "Ido", "native_name" => "Ido", "iso_639_1" => "io", "iso_639_2" => "ido"],
            ["language_family" => "Indo-European", "language" => "Icelandic", "native_name" => "Íslenska", "iso_639_1" => "is", "iso_639_2" => "isl"],
            ["language_family" => "Indo-European", "language" => "Italian", "native_name" => "italiano", "iso_639_1" => "it", "iso_639_2" => "ita"],
            ["language_family" => "Eskimo–Aleut", "language" => "Inuktitut", "native_name" => "ᐃᓄᒃᑎᑐᑦ", "iso_639_1" => "iu", "iso_639_2" => "iku"],
            ["language_family" => "Japonic", "language" => "Japanese", "native_name" => "日本語 (にほんご)", "iso_639_1" => "ja", "iso_639_2" => "jpn"],
            ["language_family" => "Austronesian", "language" => "Javanese", "native_name" => "basa Jawa", "iso_639_1" => "jv", "iso_639_2" => "jav"],
            ["language_family" => "Eskimo–Aleut", "language" => "Kalaallisut, Greenlandic", "native_name" => "kalaallisut, kalaallit oqaasii", "iso_639_1" => "kl", "iso_639_2" => "kal"],
            ["language_family" => "Dravidian", "language" => "Kannada", "native_name" => "ಕನ್ನಡ", "iso_639_1" => "kn", "iso_639_2" => "kan"],
            ["language_family" => "Nilo-Saharan", "language" => "Kanuri", "native_name" => "Kanuri", "iso_639_1" => "kr", "iso_639_2" => "kau"],
            ["language_family" => "Indo-European", "language" => "Kashmiri", "native_name" => "कश्मीरी, كشميري", "iso_639_1" => "ks", "iso_639_2" => "kas"],
            ["language_family" => "Turkic", "language" => "Kazakh", "native_name" => "қазақ тілі", "iso_639_1" => "kk", "iso_639_2" => "kaz"],
            ["language_family" => "Austroasiatic", "language" => "Khmer", "native_name" => "ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ", "iso_639_1" => "km", "iso_639_2" => "khm"],
            ["language_family" => "Niger–Congo", "language" => "Kikuyu, Gikuyu", "native_name" => "Gĩkũyũ", "iso_639_1" => "ki", "iso_639_2" => "kik"],
            ["language_family" => "Niger–Congo", "language" => "Kinyarwanda", "native_name" => "Ikinyarwanda", "iso_639_1" => "rw", "iso_639_2" => "kin"],
            ["language_family" => "Turkic", "language" => "Kyrgyz", "native_name" => "Кыргызча, Кыргыз тили", "iso_639_1" => "ky", "iso_639_2" => "kir"],
            ["language_family" => "Uralic", "language" => "Komi", "native_name" => "коми кыв", "iso_639_1" => "kv", "iso_639_2" => "kom"],
            ["language_family" => "Niger–Congo", "language" => "Kongo", "native_name" => "KiKongo", "iso_639_1" => "kg", "iso_639_2" => "kon"],
            ["language_family" => "Language isolate", "language" => "Korean", "native_name" => "한국어 (韓國語), 조선어 (朝鮮語)", "iso_639_1" => "ko", "iso_639_2" => "kor"],
            ["language_family" => "Indo-European", "language" => "Kurdish", "native_name" => "Kurdî, كوردی", "iso_639_1" => "ku", "iso_639_2" => "kur"],
            ["language_family" => "Niger–Congo", "language" => "Kwanyama, Kuanyama", "native_name" => "Kuanyama", "iso_639_1" => "kj", "iso_639_2" => "kua"],
            ["language_family" => "Indo-European", "language" => "Latin", "native_name" => "latine, lingua latina", "iso_639_1" => "la", "iso_639_2" => "lat"],
            ["language_family" => "Indo-European", "language" => "Luxembourgish, Letzeburgesch", "native_name" => "Lëtzebuergesch", "iso_639_1" => "lb", "iso_639_2" => "ltz"],
            ["language_family" => "Niger–Congo", "language" => "Ganda", "native_name" => "Luganda", "iso_639_1" => "lg", "iso_639_2" => "lug"],
            ["language_family" => "Indo-European", "language" => "Limburgish, Limburgan, Limburger", "native_name" => "Limburgs", "iso_639_1" => "li", "iso_639_2" => "lim"],
            ["language_family" => "Niger–Congo", "language" => "Lingala", "native_name" => "Lingála", "iso_639_1" => "ln", "iso_639_2" => "lin"],
            ["language_family" => "Tai–Kadai", "language" => "Lao", "native_name" => "ພາສາລາວ", "iso_639_1" => "lo", "iso_639_2" => "lao"],
            ["language_family" => "Indo-European", "language" => "Lithuanian", "native_name" => "lietuvių kalba", "iso_639_1" => "lt", "iso_639_2" => "lit"],
            ["language_family" => "Niger–Congo", "language" => "Luba-Katanga", "native_name" => "Tshiluba", "iso_639_1" => "lu", "iso_639_2" => "lub"],
            ["language_family" => "Indo-European", "language" => "Latvian", "native_name" => "latviešu valoda", "iso_639_1" => "lv", "iso_639_2" => "lav"],
            ["language_family" => "Indo-European", "language" => "Manx", "native_name" => "Gaelg, Gailck", "iso_639_1" => "gv", "iso_639_2" => "glv"],
            ["language_family" => "Indo-European", "language" => "Macedonian", "native_name" => "македонски јазик", "iso_639_1" => "mk", "iso_639_2" => "mkd"],
            ["language_family" => "Austronesian", "language" => "Malagasy", "native_name" => "fiteny malagasy", "iso_639_1" => "mg", "iso_639_2" => "mlg"],
            ["language_family" => "Austronesian", "language" => "Malay", "native_name" => "bahasa Melayu, بهاس ملايو", "iso_639_1" => "ms", "iso_639_2" => "msa"],
            ["language_family" => "Dravidian", "language" => "Malayalam", "native_name" => "മലയാളം", "iso_639_1" => "ml", "iso_639_2" => "mal"],
            ["language_family" => "Afro-Asiatic", "language" => "Maltese", "native_name" => "Malti", "iso_639_1" => "mt", "iso_639_2" => "mlt"],
            ["language_family" => "Austronesian", "language" => "Māori", "native_name" => "te reo Māori", "iso_639_1" => "mi", "iso_639_2" => "mri"],
            ["language_family" => "Indo-European", "language" => "Marathi (Marāṭhī)", "native_name" => "मराठी", "iso_639_1" => "mr", "iso_639_2" => "mar"],
            ["language_family" => "Austronesian", "language" => "Marshallese", "native_name" => "Kajin M̧ajeļ", "iso_639_1" => "mh", "iso_639_2" => "mah"],
            ["language_family" => "Mongolic", "language" => "Mongolian", "native_name" => "монгол", "iso_639_1" => "mn", "iso_639_2" => "mon"],
            ["language_family" => "Austronesian", "language" => "Nauru", "native_name" => "Ekakairũ Naoero", "iso_639_1" => "na", "iso_639_2" => "nau"],
            ["language_family" => "Dené–Yeniseian", "language" => "Navajo, Navaho", "native_name" => "Diné bizaad, Dinékʼehǰí", "iso_639_1" => "nv", "iso_639_2" => "nav"],
            ["language_family" => "Indo-European", "language" => "Norwegian Bokmål", "native_name" => "Norsk bokmål", "iso_639_1" => "nb", "iso_639_2" => "nob"],
            ["language_family" => "Niger–Congo", "language" => "North Ndebele", "native_name" => "isiNdebele", "iso_639_1" => "nd", "iso_639_2" => "nde"],
            ["language_family" => "Indo-European", "language" => "Nepali", "native_name" => "नेपाली", "iso_639_1" => "ne", "iso_639_2" => "nep"],
            ["language_family" => "Niger–Congo", "language" => "Ndonga", "native_name" => "Owambo", "iso_639_1" => "ng", "iso_639_2" => "ndo"],
            ["language_family" => "Indo-European", "language" => "Norwegian Nynorsk", "native_name" => "Norsk nynorsk", "iso_639_1" => "nn", "iso_639_2" => "nno"],
            ["language_family" => "Indo-European", "language" => "Norwegian", "native_name" => "Norsk", "iso_639_1" => "no", "iso_639_2" => "nor"],
            ["language_family" => "Sino-Tibetan", "language" => "Nuosu", "native_name" => "ꆈꌠ꒿ Nuosuhxop", "iso_639_1" => "ii", "iso_639_2" => "iii"],
            ["language_family" => "Niger–Congo", "language" => "South Ndebele", "native_name" => "isiNdebele", "iso_639_1" => "nr", "iso_639_2" => "nbl"],
            ["language_family" => "Indo-European", "language" => "Occitan", "native_name" => "occitan, lenga d'òc", "iso_639_1" => "oc", "iso_639_2" => "oci"],
            ["language_family" => "Algonquian", "language" => "Ojibwe, Ojibwa", "native_name" => "ᐊᓂᔑᓈᐯᒧᐎᓐ", "iso_639_1" => "oj", "iso_639_2" => "oji"],
            ["language_family" => "Indo-European", "language" => "Old Church Slavonic, Church Slavonic, Old Bulgarian", "native_name" => "ѩзыкъ словѣньскъ", "iso_639_1" => "cu", "iso_639_2" => "chu"],
            ["language_family" => "Afro-Asiatic", "language" => "Oromo", "native_name" => "Afaan Oromoo", "iso_639_1" => "om", "iso_639_2" => "orm"],
            ["language_family" => "Indo-European", "language" => "Oriya", "native_name" => "ଓଡ଼ିଆ", "iso_639_1" => "or", "iso_639_2" => "ori"],
            ["language_family" => "Indo-European", "language" => "Ossetian, Ossetic", "native_name" => "ирон æвзаг", "iso_639_1" => "os", "iso_639_2" => "oss"],
            ["language_family" => "Indo-European", "language" => "Panjabi, Punjabi", "native_name" => "ਪੰਜਾਬੀ, پنجابی", "iso_639_1" => "pa", "iso_639_2" => "pan"],
            ["language_family" => "Indo-European", "language" => "Pāli", "native_name" => "पाऴि", "iso_639_1" => "pi", "iso_639_2" => "pli"],
            ["language_family" => "Indo-European", "language" => "Persian (Farsi)", "native_name" => "فارسی", "iso_639_1" => "fa", "iso_639_2" => "fas"],
            ["language_family" => "Indo-European", "language" => "Polish", "native_name" => "język polski, polszczyzna", "iso_639_1" => "pl", "iso_639_2" => "pol"],
            ["language_family" => "Indo-European", "language" => "Pashto, Pushto", "native_name" => "پښتو", "iso_639_1" => "ps", "iso_639_2" => "pus"],
            ["language_family" => "Indo-European", "language" => "Portuguese", "native_name" => "português", "iso_639_1" => "pt", "iso_639_2" => "por"],
            ["language_family" => "Quechuan", "language" => "Quechua", "native_name" => "Runa Simi, Kichwa", "iso_639_1" => "qu", "iso_639_2" => "que"],
            ["language_family" => "Indo-European", "language" => "Romansh", "native_name" => "rumantsch grischun", "iso_639_1" => "rm", "iso_639_2" => "roh"],
            ["language_family" => "Niger–Congo", "language" => "Kirundi", "native_name" => "Ikirundi", "iso_639_1" => "rn", "iso_639_2" => "run"],
            ["language_family" => "Indo-European", "language" => "Romanian", "native_name" => "limba română", "iso_639_1" => "ro", "iso_639_2" => "ron"],
            ["language_family" => "Indo-European", "language" => "Russian", "native_name" => "русский язык", "iso_639_1" => "ru", "iso_639_2" => "rus"],
            ["language_family" => "Indo-European", "language" => "Sanskrit (Saṁskṛta)", "native_name" => "संस्कृतम्", "iso_639_1" => "sa", "iso_639_2" => "san"],
            ["language_family" => "Indo-European", "language" => "Sardinian", "native_name" => "sardu", "iso_639_1" => "sc", "iso_639_2" => "srd"],
            ["language_family" => "Indo-European", "language" => "Sindhi", "native_name" => "सिन्धी, سنڌي، سندھی", "iso_639_1" => "sd", "iso_639_2" => "snd"],
            ["language_family" => "Uralic", "language" => "Northern Sami", "native_name" => "Davvisámegiella", "iso_639_1" => "se", "iso_639_2" => "sme"],
            ["language_family" => "Austronesian", "language" => "Samoan", "native_name" => "gagana fa'a Samoa", "iso_639_1" => "sm", "iso_639_2" => "smo"],
            ["language_family" => "Creole", "language" => "Sango", "native_name" => "yângâ tî sängö", "iso_639_1" => "sg", "iso_639_2" => "sag"],
            ["language_family" => "Indo-European", "language" => "Serbian", "native_name" => "српски језик", "iso_639_1" => "sr", "iso_639_2" => "srp"],
            ["language_family" => "Indo-European", "language" => "Scottish Gaelic; Gaelic", "native_name" => "Gàidhlig", "iso_639_1" => "gd", "iso_639_2" => "gla"],
            ["language_family" => "Niger–Congo", "language" => "Shona", "native_name" => "chiShona", "iso_639_1" => "sn", "iso_639_2" => "sna"],
            ["language_family" => "Indo-European", "language" => "Sinhala, Sinhalese", "native_name" => "සිංහල", "iso_639_1" => "si", "iso_639_2" => "sin"],
            ["language_family" => "Indo-European", "language" => "Slovak", "native_name" => "slovenčina, slovenský jazyk", "iso_639_1" => "sk", "iso_639_2" => "slk"],
            ["language_family" => "Indo-European", "language" => "Slovene", "native_name" => "slovenski jezik, slovenščina", "iso_639_1" => "sl", "iso_639_2" => "slv"],
            ["language_family" => "Afro-Asiatic", "language" => "Somali", "native_name" => "Soomaaliga, af Soomaali", "iso_639_1" => "so", "iso_639_2" => "som"],
            ["language_family" => "Niger–Congo", "language" => "Southern Sotho", "native_name" => "Sesotho", "iso_639_1" => "st", "iso_639_2" => "sot"],
            ["language_family" => "Turkic", "language" => "South Azerbaijani", "native_name" => "تورکجه", "iso_639_1" => "az", "iso_639_2" => "azb"],
            ["language_family" => "Indo-European", "language" => "Spanish; Castilian", "native_name" => "español, castellano", "iso_639_1" => "es", "iso_639_2" => "spa"],
            ["language_family" => "Austronesian", "language" => "Sundanese", "native_name" => "Basa Sunda", "iso_639_1" => "su", "iso_639_2" => "sun"],
            ["language_family" => "Niger–Congo", "language" => "Swahili", "native_name" => "Kiswahili", "iso_639_1" => "sw", "iso_639_2" => "swa"],
            ["language_family" => "Niger–Congo", "language" => "Swati", "native_name" => "SiSwati", "iso_639_1" => "ss", "iso_639_2" => "ssw"],
            ["language_family" => "Indo-European", "language" => "Swedish", "native_name" => "Svenska", "iso_639_1" => "sv", "iso_639_2" => "swe"],
            ["language_family" => "Dravidian", "language" => "Tamil", "native_name" => "தமிழ்", "iso_639_1" => "ta", "iso_639_2" => "tam"],
            ["language_family" => "Dravidian", "language" => "Telugu", "native_name" => "తెలుగు", "iso_639_1" => "te", "iso_639_2" => "tel"],
            ["language_family" => "Indo-European", "language" => "Tajik", "native_name" => "тоҷикӣ, toğikī, تاجیکی", "iso_639_1" => "tg", "iso_639_2" => "tgk"],
            ["language_family" => "Tai–Kadai", "language" => "Thai", "native_name" => "ไทย", "iso_639_1" => "th", "iso_639_2" => "tha"],
            ["language_family" => "Afro-Asiatic", "language" => "Tigrinya", "native_name" => "ትግርኛ", "iso_639_1" => "ti", "iso_639_2" => "tir"],
            ["language_family" => "Sino-Tibetan", "language" => "Tibetan Standard, Tibetan, Central", "native_name" => "བོད་ཡིག", "iso_639_1" => "bo", "iso_639_2" => "bod"],
            ["language_family" => "Turkic", "language" => "Turkmen", "native_name" => "Türkmen, Түркмен", "iso_639_1" => "tk", "iso_639_2" => "tuk"],
            ["language_family" => "Austronesian", "language" => "Tagalog", "native_name" => "Wikang Tagalog, ᜏᜒᜃᜅ᜔ ᜆᜄᜎᜓᜄ᜔", "iso_639_1" => "tl", "iso_639_2" => "tgl"],
            ["language_family" => "Niger–Congo", "language" => "Tswana", "native_name" => "Setswana", "iso_639_1" => "tn", "iso_639_2" => "tsn"],
            ["language_family" => "Austronesian", "language" => "Tonga (Tonga Islands)", "native_name" => "faka Tonga", "iso_639_1" => "to", "iso_639_2" => "ton"],
            ["language_family" => "Turkic", "language" => "Turkish", "native_name" => "Türkçe", "iso_639_1" => "tr", "iso_639_2" => "tur"],
            ["language_family" => "Niger–Congo", "language" => "Tsonga", "native_name" => "Xitsonga", "iso_639_1" => "ts", "iso_639_2" => "tso"],
            ["language_family" => "Turkic", "language" => "Tatar", "native_name" => "татар теле, tatar tele", "iso_639_1" => "tt", "iso_639_2" => "tat"],
            ["language_family" => "Niger–Congo", "language" => "Twi", "native_name" => "Twi", "iso_639_1" => "tw", "iso_639_2" => "twi"],
            ["language_family" => "Austronesian", "language" => "Tahitian", "native_name" => "Reo Tahiti", "iso_639_1" => "ty", "iso_639_2" => "tah"],
            ["language_family" => "Turkic", "language" => "Uyghur, Uighur", "native_name" => "Uyƣurqə, ئۇيغۇرچە", "iso_639_1" => "ug", "iso_639_2" => "uig"],
            ["language_family" => "Indo-European", "language" => "Ukrainian", "native_name" => "українська мова", "iso_639_1" => "uk", "iso_639_2" => "ukr"],
            ["language_family" => "Indo-European", "language" => "Urdu", "native_name" => "اردو", "iso_639_1" => "ur", "iso_639_2" => "urd"],
            ["language_family" => "Turkic", "language" => "Uzbek", "native_name" => "O‘zbek, Ўзбек, أۇزبېك", "iso_639_1" => "uz", "iso_639_2" => "uzb"],
            ["language_family" => "Niger–Congo", "language" => "Venda", "native_name" => "Tshivenḓa", "iso_639_1" => "ve", "iso_639_2" => "ven"],
            ["language_family" => "Austroasiatic", "language" => "Vietnamese", "native_name" => "Tiếng Việt", "iso_639_1" => "vi", "iso_639_2" => "vie"],
            ["language_family" => "Constructed", "language" => "Volapük", "native_name" => "Volapük", "iso_639_1" => "vo", "iso_639_2" => "vol"],
            ["language_family" => "Indo-European", "language" => "Walloon", "native_name" => "walon", "iso_639_1" => "wa", "iso_639_2" => "wln"],
            ["language_family" => "Indo-European", "language" => "Welsh", "native_name" => "Cymraeg", "iso_639_1" => "cy", "iso_639_2" => "cym"],
            ["language_family" => "Niger–Congo", "language" => "Wolof", "native_name" => "Wollof", "iso_639_1" => "wo", "iso_639_2" => "wol"],
            ["language_family" => "Indo-European", "language" => "Western Frisian", "native_name" => "Frysk", "iso_639_1" => "fy", "iso_639_2" => "fry"],
            ["language_family" => "Niger–Congo", "language" => "Xhosa", "native_name" => "isiXhosa", "iso_639_1" => "xh", "iso_639_2" => "xho"],
            ["language_family" => "Indo-European", "language" => "Yiddish", "native_name" => "ייִדיש", "iso_639_1" => "yi", "iso_639_2" => "yid"],
            ["language_family" => "Niger–Congo", "language" => "Yoruba", "native_name" => "Yorùbá", "iso_639_1" => "yo", "iso_639_2" => "yor"],
            ["language_family" => "Tai–Kadai", "language" => "Zhuang, Chuang", "native_name" => "Saɯ cueŋƅ, Saw cuengh", "iso_639_1" => "za", "iso_639_2" => "zha"],
            ["language_family" => "Niger–Congo", "language" => "Zulu", "native_name" => "isiZulu", "iso_639_1" => "zu", "iso_639_2" => "zul"],

        ];

        DB::beginTransaction();

        try {
            foreach ($list as $language) {

                $language['id'] = $language['iso_639_2'];

                $existing = HCLanguages::where ('id', $language['id'])->first ();

                if (!$existing)
                    HCLanguages::create($language);
            }
        } catch (\Exception $e) {
            DB::rollback();

            throw new Exception($e->getMessage());
        }

        DB::commit();
    }
}