/** * */ function script($attributes, $text = '') { if (!empty($text)) { $text = '//<![CDATA[ ' . "\n" . $text . "\n" . '//]]>'; } else { $text = ''; } $script = '<script '; $script .= array_join_assoc($attributes, '="', '" '); $script .= '>'; $script .= $text; $script .= '</script>'; return $script; }
protected static function establish_connection($name) { if (isset(self::$configurations[$name])) { $configuration = self::$configurations[$name]; if (!isset($configuration['dbname'])) { $configuration['dbname'] = array_delete('database', $configuration); } $adapter = array_delete('adapter', $configuration); $username = array_delete('username', $configuration); $password = array_delete('password', $configuration); $connection_string = $adapter . ':'; $connection_string .= $adapter == 'sqlite' ? $configuration['dbname'] : array_join_assoc('=', ';', $configuration); self::$connections[$name] = new PDO($connection_string, $username, $password); } else { throw new InvalidArgumentException('Database configuration "' . $name . '" does not exist'); } }
/** * Join an keys and values of an array */ public function testArrayJoinAssoc() { $array = ['foo' => 'bar', 'faa' => 'bor']; $this->assertEquals(array_join_assoc($array, '=', '&'), 'foo=bar&faa=bor'); $this->assertEquals(array_join_assoc($array, ':', ','), 'foo:bar,faa:bor'); }