Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix last commit: Add components basic API | <?php
use Parvula\FilesSystem;
$path = _PLUGINS_ . '/_Components';
// list components
$this->get('', function ($req, $res) use ($path) {
$acc = [];
foreach(glob($path . '/*.php', GLOB_NOSORT) as $file) {
$file = basename($file);
if ($file[0] !== '_') {
$acc[] = $file;
}
}
return $this->api->json($res, ... | |
Add interface for factory to create spec | <?php
namespace Cs278\BankModulus\Spec;
interface SpecFactoryInterface
{
/**
* Create specification and return.
*
* Implementations may create and hold singletons rather than returning a
* new object on each method call, however any state (e.g. current time)
* should be checked for validi... | |
Fix typo error. Typo on copyright comment. | <?php
/**
* This file is part of the Bruery Platform.
*
* (c) Viktore Zara <viktore.zara@gmail.com>
* (c) Mell Zamora <mellzamora@outlook.com>
*
* Copyright (c) 2016. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/
*/
namespace Bruer... | <?php
/**
* This file is part of the Bruery Platform.
*
* (c) Viktore Zara <viktore.zara@gmail.com>
* (c) Mell Zamora <mellzamora@outlook.com>
*
* Copyright (c) 2016. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/
namespace Bruery\Us... |
Allow editing cms_config.php by manager | <!DOCTYPE html>
<html>
<head>
<?php include 'includes.php'; ?>
<title>Reünie Nehalennia</title>
</head>
<?php
if (is_string($_POST["password"])) {
if ($_POST["password"] == $config["results-password"]) {
if (is_string($_POST["cms-config"])) {
// Correct password, sent a ne... | |
Add PHPUnit tests for Stripe_ApplicationFeeRefund | <?php
class Stripe_ApplicationFeeRefundTest extends Stripe_TestCase
{
public function testUrls()
{
$refund = new Stripe_ApplicationFeeRefund();
$refund->id = 'refund_id';
$refund->fee = 'fee_id';
$this->assertSame(
$refund->instanceUrl(),
'/v1/application_fees/fee_id/refunds/refund... | |
Add migration for new attribute | <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddUserFirstlogin extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('wuser', function (Bluep... | |
Add test for main class | <?php
/*
* This file is part of the phpToolBox package.
*
* (c) Brack Romain <http://www.cyberomulus.me>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cyberomulus\PhpToolbox\tests;
use Cyberomulus\PhpToolbox\PhpToolbo... | |
Add very basic query class | <?php
/**
* Purity5 is a HTML5 parser
*
* @author Skylar Kelty <skylarkelty@gmail.com>
*/
namespace SkylarK\Purity5\DataStructures;
/**
* A Query is used to breakup a string into a set of rules and match
* PureTrees against those rules
*/
class Query
{
/** Stored raw string */
private $_query;
/**
* Con... | |
Add unit test for BasicAuthenticationCredentials | <?php
namespace Marein\Nchan\Http\Adapter;
use Marein\Nchan\Http\Request;
use PHPUnit\Framework\TestCase;
class BasicAuthenticationCredentialsTest extends TestCase
{
/**
* @test
*/
public function itShouldExpandTheRequestWithAuthenticationHeader()
{
$username = 'starwars';
$pass... | |
Add basic tests for product object | <?php
namespace MageTitans\Workshop\Domain\Product;
use MageTitans\Workshop\Domain\Stock\Stock;
use MageTitans\Workshop\Domain\Stock\StockInterface;
use PHPUnit\Framework\TestCase;
final class ProductTest extends TestCase
{
public function testGetStock()
{
$stock = new Stock(
true,
... | |
Add a bootstrapper to allow OOMs to be handled | <?php
namespace Bugsnag\BugsnagLaravel;
class OomBootstrapper
{
/**
* A bit of reserved memory to ensure we are able to increase the memory
* limit on an OOM.
*
* We can't reserve all of the memory that we need to send OOM reports
* because this would have a big overhead on every request,... | |
Add some initial tests for the new SimpleSAML\Locale\Language class. | <?php
namespace SimpleSAML\Test\Locale;
use SimpleSAML\Locale\Language;
class LanguageTest extends \PHPUnit_Framework_TestCase
{
/**
* Test SimpleSAML\Locale\Language::getLanguageCookie().
*/
public function testGetLanguageCookie()
{
// test it works when no cookie is set
\Sim... | |
Add example with blpop with timeout | <?php
require __DIR__ . "/../vendor/autoload.php";
Amp\run(function () {
$client = new Amp\Redis\Client("tcp://localhost:6379");
yield $client->del("foobar-list");
Amp\repeat(function () {
print "Waiting for blpop…" . PHP_EOL;
}, 1000);
$value = yield $client->blpop("foobar-list", 5);
... | |
Add a script for decaching an object | #!/usr/bin/env php
<?php
/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, ... | |
Add migration for right answer | <?php
/**
* Data object containing the SQL and PHP code to migrate the database
* up to version 1382246909.
* Generated on 2013-10-20 07:28:29 by smirik
*/
class PropelMigration_1382246909
{
public function preUp($manager)
{
// add the pre-migration code here
}
public function postUp($man... | |
Add compiler pass for registering commands | <?php
namespace Ibuildings\QaTools\Core\Application\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
final class CommandsCompilerPass implements CompilerPassInterfac... | |
Add example of keyed shutdown. | <?php
namespace Gielfeldt\Example;
require 'vendor/autoload.php';
use Gielfeldt\ShutdownHandler;
/**
* Simple shutdown handler callback.
*
* @param string $message
* Message to display during shutdown.
*/
function myshutdownhandler($message = '')
{
echo "Goodbye $message\n";
}
// Register shutdown handl... | |
Change data type for JSON fields | <?php
/**
* Migration: 10
* Started: 29/04/2021
*
* @package Nails
* @subpackage module-cms
* @category Database Migration
* @author Nails Dev Team
*/
namespace Nails\Cms\Database\Migration;
use Nails\Common\Console\Migrate\Base;
/**
* Class Migration10
*
* @package Nails\Database\Migratio... | |
Create a custom translator class | <?php namespace Modules\Translation\Services;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Modules\Translation\Events\TranslationNotFoundInCache;
use Modules\Translation\Repositories\CacheTranslation;
use Modules\Translation\Repositories\TranslationRepository;
class Translator extends \Illuminate\Translation\Tra... | |
Add a patch file to rename wiki pages without a name, and also remove prefs with value NULL, which both can contribute to a "No wiki page specified" error on tiki-index.php | <?php
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
/**
* In some upgrade cases pages without a name can cause a "No wiki page specified" error on tiki-index.php
* Also the pref wikiHomePage can be set to NULL causing the same error
*
* @param Install... | |
Allow to add serializers through config | <?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace ... | |
Allow null for optional talk fields | <?php
use Phinx\Migration\AbstractMigration;
class AlterTalkColumnsAllowNull extends AbstractMigration
{
/**
* Migrate Up.
*/
public function up()
{
$this->table('talks')
->changeColumn('other', 'text', ['null' => true])
->changeColumn('slides', 'string', ['null' =... | |
Add tests for the priority class | <?php
namespace Common\Tests\Core\Header;
use Common\Core\Header\Priority;
use PHPUnit\Framework\TestCase;
class PriorityTest extends TestCase
{
public function testPriorityEquals(): void
{
$this->assertTrue(Priority::widget()->equals(Priority::widget()));
}
public function testPriorityNotEq... | |
Add field for Stripe Payment Intent API | <?php
use Phinx\Migration\AbstractMigration;
class AddStripePaymentIntent extends AbstractMigration
{
public function change()
{
$table= $this->table('sale');
$table
->addColumn('stripe_payment_intent_id', 'string', [
'limit' => 255,
'null' => true,
'after' =>... | |
Add compiler pass for provider extensions - fix service id after merge | <?php
namespace Oro\Bundle\ActionBundle\DependencyInjection\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Oro\Component\DependencyInjection\Compiler\TaggedServicesCompilerPassTrait;
class ButtonProviderPass imp... | <?php
namespace Oro\Bundle\ActionBundle\DependencyInjection\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Oro\Component\DependencyInjection\Compiler\TaggedServicesCompilerPassTrait;
class ButtonProviderPass imp... |
Implement the site-wide search controller. | <?php
App::uses('AppController', 'Controller');
/**
* Search controller
*
* Handles site-wide search.
*/
class SearchController extends AppController
{
public function this($description, $start = 0)
{
$products = $this->requestAction(array(
'controller' => 'products',
'action' => 'search'),
array('pas... | |
Make a stub for manager section | <?php
namespace Listabierta\Bundle\MunicipalesBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Listabierta\Bundle\MunicipalesBundle\Entity\PhoneVerified;
class ManagerController extends Control... | |
Reorder methods to match interface | <?php
namespace FullyBaked\Pslackr\Messages;
class CustomMessage implements Message
{
protected $text;
public function asJson()
{
$message = [
'text' => $this->text
];
return json_encode($message);
}
public function text($text)
{
$this->text = $tex... | |
Add client & user indexes to refresh tokens. | <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddMoreIndexesToRefreshTokens extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('refresh_tokens', function (Blueprint $collec... | |
Add the membership request page | <!DOCTYPE HTML>
<html lang="it">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <meta name="description" content="Vuoi imparare il russo parlato e scritto in maniera coinvolgente, divertente e sempre motiva... | |
Add fields to Payments table to store payment processor-related metadata | <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddPaymentProcessorFieldsToPayments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table(... | |
Add new migration in messageboard module | <?php
/**
* add columns to users
*
*/
namespace Fuel\Migrations;
class Add_users_deleted_column
{
function up()
{
if(!\DBUtil::field_exists('users', array('deleted')))
{
\DBUtil::add_fields(
'users',
array(
'deleted' => array(
'type' => 'tinyint',
'default' => 0,
),
)
)... | |
Validate issuer even if none in payload | <?php
namespace Emarref\Jwt\Verification;
use Emarref\Jwt\Claim;
use Emarref\Jwt\Encoding;
use Emarref\Jwt\Exception\VerificationException;
use Emarref\Jwt\HeaderParameter;
use Emarref\Jwt\Token;
class IssuerVerifier implements VerifierInterface
{
/**
* @var string
*/
private $issuer;
/**
... | <?php
namespace Emarref\Jwt\Verification;
use Emarref\Jwt\Claim;
use Emarref\Jwt\Encoding;
use Emarref\Jwt\Exception\VerificationException;
use Emarref\Jwt\HeaderParameter;
use Emarref\Jwt\Token;
class IssuerVerifier implements VerifierInterface
{
/**
* @var string
*/
private $issuer;
/**
... |
Add test for SegmentQueryConverter - added test | <?php
namespace Oro\Bundle\SegmentBundle\Tests\Functional\Query;
use Oro\Bundle\SegmentBundle\Model\RestrictionSegmentProxy;
use Oro\Bundle\SegmentBundle\Query\SegmentQueryConverter;
use Oro\Bundle\SegmentBundle\Tests\Functional\DataFixtures\LoadSegmentData;
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;
class... | |
Add dummy test to avoid Travis builds to fail. | <?php
namespace Afonso\Soapi\Tests;
use PHPUnit_Framework_TestCase;
class SoapiTest extends PHPUnit_Framework_TestCase
{
public function testSoapi()
{
/*
* Temporary placeholder test to avoid
* Travis builds to fail.
*/
}
}
| |
Add an interface to define custom form and load/save handlers | <?php
namespace DDPro\Admin\Config;
/**
* Interface ModelServiceInterface
*
* This interface is used when a model config wants to provide a custom form with a custom
* load / save handler for a model.
*
* The functions contained here include:
*
* * getBladeViewIndex -- provide a custom index page.
* * getBla... | |
Change data field for sprint snapshots to longText. | <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeDataTypeToLongtext extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$this->dropColumn();
Schema::table('sprint_snapshots', function($t)
{
$t->longText... | |
Add tests for file loader | <?php
namespace Becklyn\AssetsBundle\tests\File;
use Becklyn\AssetsBundle\Entry\EntryNamespaces;
use Becklyn\AssetsBundle\File\FileLoader;
use Becklyn\AssetsBundle\Processor\ProcessorRegistry;
use PHPUnit\Framework\TestCase;
class FileLoaderTest extends TestCase
{
/**
* @var FileLoader
*/
private ... | |
Add migration for AccountPlan entity | <?php
namespace Application\Migrations;
use SimplyTestable\BaseMigrationsBundle\Migration\BaseMigration,
Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your need!
*/
class Version20130425145821_add_AccountPlan extends BaseMigration
{
public function up(Schema $schema)
... | |
Refactor hprose server and client based on swoole | <?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| ... | |
Add list dataset (sample) script. | <?php
/**
* List dataset(s)
* Written by Ryan Yonzon <hello@ryanyonzon.com>
*/
set_include_path("vendor/google/apiclient/src/" . PATH_SEPARATOR . get_include_path());
require_once 'Google/Client.php';
require_once 'Google/Service/Bigquery.php';
// configuration stuff
$config = require_once 'config/Credentials.php... | |
Test if QueryConstraintGroup is valid | <?php
class SqlQuerySelectDataConstraintGroupTest extends MidgardTest
{
protected $select = null;
protected $mgd = null;
public function setUp()
{
$this->mgd = midgard_connection::get_instance();
if ($this->select === null) {
$this->select = new MidgardSqlQuerySelectData(m... | |
Add French translation for Kcaptcha | <?php defined('BASEPATH') OR exit('No direct script access allowed');
$lang['captcha.label'] = '%sSaisissez le texte affiché dans l\'image';
$lang['captcha.tip'] = 'Cliquez sur l\'image si vous n\'êtes pas capable de lire le texte proposé.';
$lang['captcha.validation_error'] = 'Vous n\'avez pas entrer correctement le ... | |
Add messenger service provider for Laravel support | <?php namespace Nathanmac\InstantMessenger;
use Illuminate\Support\ServiceProvider;
class MessengerServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Boot the service provider.
*
... | |
Add test case for basic `set` and `get` | <?php
namespace RockSymfony\ServiceContainer\Tests;
use PHPUnit\Framework\TestCase;
use RockSymfony\ServiceContainer\ServiceContainer;
class SetAndGetTest extends TestCase
{
/** @var ServiceContainer */
private $container;
protected function setUp()
{
$this->container = new ServiceContain... | |
Add a small script to test HTTP request / responses | <?php
require __DIR__ . '/bootstrap.php';
function json_response($array)
{
header('Content-Type: application/json');
echo json_encode($array);
exit;
}
$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : '';
use Ockcyp\WpPostsCli\Parser\Command as CommandParser;
$commandParser = new CommandParser;
if (!$comman... | |
Make the nav a partial | <img class="logo" title="Laravel Logo" alt="Laravel Logo" src="img/laravel.svg">
<span class="social-icons">
<a href="{{ $meetup_url }}" title="Link to the Laravel Brussels group on Meetup.com>
<i class=" fa fa-3x fa-meetup" aria-hidden="true"></i>
</a>
<a href="//twitter.com/{{ $twitter }}" title="... | |
Add basic consent API functional test | <?php
namespace OpenConext\EngineBlockBundle\Tests;
use Liip\FunctionalTestBundle\Test\WebTestCase;
use OpenConext\EngineBlockBundle\Configuration\Feature;
use OpenConext\EngineBlockBundle\Configuration\FeatureConfiguration;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Component\HttpFoundation\Response;
fi... | |
Add abstract controller with support catch exception in ajax | <?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Phalex\Mvc;
use Exception;
use Phalcon\Mvc\Controller;
use Phalex\Http\ResponseJson;
/**
* Description of Abstract... | |
Move cache access to separate class | <?php
/**
* Humbug
*
* @category Humbug
* @package Humbug
* @copyright Copyright (c) 2015 Pádraic Brady (http://blog.astrumfutura.com)
* @license https://github.com/padraic/humbug/blob/master/LICENSE New BSD License
*/
namespace Humbug\TestSuite\Mutant;
use Humbug\File\Collector as FileCollector;
use ... | |
Add invalid argument exception for engine block bundle | <?php
namespace OpenConext\EngineBlockBundle\Exception;
use InvalidArgumentException as CoreInvalidArgumentException;
class InvalidArgumentException extends CoreInvalidArgumentException
{
public static function invalidType($expectedType, $propertyPath, $parameter)
{
return new self(
sprin... | |
Add class to handle YAML export output file | <?php
namespace Bolt\Database\Migration\Output;
use Bolt\Database\Migration\Export;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Yaml\Dumper;
/**
* YAML export file
*
* @author Gawain Lynch <gawain.lynch@gmail.com>
*/
class YamlFile implements OutputFileInterface
{
/** @var Export $e... | |
Complete fixing of improperly named tf2 in db | <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Pterodactyl\Models\ServiceOptions;
class RenameDoubleInsurgency extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
... | |
Add class connection to the database with PDO | <?php
class dbConnection{
public static function connectedDB(){
try{
$base = new PDO('mysql:host=localhost; dbname=FirstConnection','root','7lp3cqmfF4:13');
//echo "Connection with the database succesfully";
//?
$base-> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//for... | |
Use PHP script for namespacing | <?php
$path = __DIR__ . '/../src/DebugBar/Resources/vendor/font-awesome/css/font-awesome.min.css';
$contents = file_get_contents($path);
if (strpos($contents, 'PhpDebugbarFontAwesome') !== false ){
exit('Already namespaced');
}
// namespace FontAwesome occurrences
$contents = str_replace(['FontAwesome', 'fa-', '... | |
Add new page with events sidebar hard coded | <?php
/**
* Template Name: Page with Event Sidebar
*/
get_header();
if (Bunyad::posts()->meta('featured_slider')):
get_template_part('partial-sliders');
endif;
?>
<div class="main wrap cf">
<div class="row">
<div class="col-8 main-content">
<?php if (have_posts()): the_post(); endif; // loa... | |
Add simple HTTP client as example | <?php // basic (and dumb) HTTP client
require __DIR__ . '/../vendor/autoload.php';
// This is a very simple HTTP client that just prints the response without parsing.
use Amp\ByteStream\ResourceOutputStream;
use Amp\Loop;
use function Amp\asyncCoroutine;
use function Amp\Socket\connect;
use function Amp\Socket\crypt... | |
Add example page for link 3 | <?php
$currentPage = "link_3";
require_once("config.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>AdaptiveNav v2.0 - Responsive Navigation Menu</title>
<meta name="viewport" content="width=device-width, initial-s... | |
Add tool to generate Acls programatically | <?php
namespace Croogo\Acl;
use Acl\AclExtras;
use Cake\Database\Exception;
use Cake\Datasource\ConnectionInterface;
use Cake\ORM\TableRegistry;
use Croogo\Core\Plugin;
class AclGenerator extends AclExtras
{
public function __construct()
{
$this->Aco = TableRegistry::get('Croogo/Acl.Acos');
$... | |
Add a listener to guarantee initialized AuthenticationState | <?php
/**
* Copyright 2016 SURFnet B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... | |
Add a service for interacting with Packagist. | <?php
use Composer\Factory;
use Composer\IO\NullIO;
use Composer\Package\Loader\ArrayLoader;
use Composer\Repository\ComposerRepository;
use Guzzle\Http\Client;
/**
* Interacts with Packagist to retrieve package listings and details.
*/
class PackagistService {
const PACKAGIST_URL = 'https://packagist.org';
/**... | |
Add DB adapter factory for the service manager | <?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Z... | |
Update Lambda Helper docblock. It was a lie. | <?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Lambda Helper.
*
* Passed to section and interpolation lambdas, giving them access to a `... | <?php
/*
* This file is part of Mustache.php.
*
* (c) 2012 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Mustache Lambda Helper.
*
* Passed as the second argument to section lambdas (higher order section... |
Check if client IP needs 2FA Here you can enter a range op IPs. If the client is in the range, it does not need 2FA | <?php
/**
* This authproc filter enables the possibility to check which IP the client has.
* If it is wanted, the IDP is able to disable 2FA for special clients.
* For example a user, which is located in the local area network, does not need 2FA
* @author Micha Preußer <micha.preusser@netknights.it>
*/
class sspm... | |
Create util to generate code | <?php
echo generateRandomString(8)."\n";
function generateRandomString($length = 10) {
return substr(str_shuffle("0123456789abcdefghjkmnopqrstuvwxyz"), 0, $length);
} | |
Add 'comment' field to list of non-numeric fields. | <?php
class JsonView extends ApiView {
public function render($content) {
header('Content-Type: application/json; charset=utf8');
echo $this->buildOutput($content);
return true;
}
/**
* Function to build output, can be used by JSON and JSONP
*/
public function buildO... | <?php
class JsonView extends ApiView {
public function render($content) {
header('Content-Type: application/json; charset=utf8');
echo $this->buildOutput($content);
return true;
}
/**
* Function to build output, can be used by JSON and JSONP
*/
public function buildO... |
Add DatabaseBehaviorAccessible to handle row access based on the active users group, role or authenticity. | <?php
/**
* Nooku Platform - http://www.nooku.org/platform
*
* @copyright Copyright (C) 2007 - 2014 Johan Janssens and Timble CVBA. (http://www.timble.net)
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link https://github.com/nooku/nooku-platform for the canonical source repository
*/
namespac... | |
Use commas for the CSV Reader | <?php
namespace Ddeboer\DataImport\Reader\Factory;
use Ddeboer\DataImport\Reader\CsvReader;
/**
* Factory that creates CsvReaders
*
*/
class CsvReaderFactory
{
protected $delimiter;
protected $enclosure;
protected $escape;
protected $headerRowNumber;
protected $strict;
public function __c... | <?php
namespace Ddeboer\DataImport\Reader\Factory;
use Ddeboer\DataImport\Reader\CsvReader;
/**
* Factory that creates CsvReaders
*
*/
class CsvReaderFactory
{
protected $delimiter;
protected $enclosure;
protected $escape;
protected $headerRowNumber;
protected $strict;
public function __c... |
Add a product in a postUp() during migration | <?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Jmlamo\DemoBundle\Entity\Product;
/**
* Auto-generated Migrati... | |
Add a file to show the hooks for islandora_bookmark. | <?php
/**
* @file
* Hooks provided by Islandora Bookmark.
*/
/**
* Hook to collect exports functions available for use.
*
* @return
* Returns an array with the name of the module and the function name to call
* to handle exportation. In the form of 'module name' => 'export function'.
*/
function... | |
Create a List Command for repositories | <?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Stephane HULARD <s.hulard@chstudio.fr>
* @package GitServiceMove\Command\BitBucket\Repository
*/
namespace GitServiceMove\Command\BitBucket\Repository;
use GitService... | |
Add a comparator to help with writing tests | <?php
namespace MyCLabs\Enum\PHPUnit;
use MyCLabs\Enum\Enum;
use SebastianBergmann\Comparator\ComparisonFailure;
/**
* Use this Comparator to get nice output when using PHPUnit assertEquals() with Enums.
*
* Add this to your PHPUnit bootstrap PHP file:
*
* \SebastianBergmann\Comparator\Factory::getInstance()->r... | |
Add migration for configured institutions | <?php
namespace Surfnet\StepupMiddleware\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160719090050 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public funct... | |
Add Array utility library, currently containing only two methods. | <?php
class ArrayUtils
{
static public function fromSingleton($input)
{
if(!is_array($input)) {
$input = array($input);
}
return $input;
}
static public function fromSingletonIfNotNull($input)
{
if($input) {
$input = self::fromSingleton($input);
}
return $input;
}
}
| |
Add shell to update existing password hashes | <?php
App::import('Security', 'Utility');
class UpdatePasswordVersionShell extends AppShell {
public $uses = array('User');
public function main() {
echo "Updating password hashes";
$proceeded = $this->batchOperation(
'User',
'_updateHash',
array(
... | |
Add view user images tests | <?php
namespace Tests\Feature;
use Tests\IntegrationTestCase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ViewUserImagesTest extends IntegrationTestCase
{
use DatabaseMigrations;
/** @test */
public function a... | |
Use internal RSS 2.0 parser | <?php
define("FREENEWS_RSS", 'http://feeds.feedburner.com/Freenews-Freebox?format=xml');
class FreenewsBridge extends FeedExpander {
const MAINTAINER = "mitsukarenai";
const NAME = "Freenews";
const URI = "http://freenews.fr";
const DESCRIPTION = "Un site d'actualité pour les freenautes (mais ne parlant pas que de... | <?php
class FreenewsBridge extends FeedExpander {
const MAINTAINER = "mitsukarenai";
const NAME = "Freenews";
const URI = "http://freenews.fr";
const DESCRIPTION = "Un site d'actualité pour les freenautes (mais ne parlant pas que de la freebox). Ne rentrez pas d'id si vous voulez accéder aux actualités... |
Configure repository - added stub test | <?php
namespace Okvpn\Bundle\RedisQueueBundle\Test\Transport\Redis;
use Okvpn\Bundle\RedisQueueBundle\Transport\Redis\RedisKey;
class RedisKeyTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider methodInvokeProvider
*
* @param string $name
* @param string $methodName
* @param s... | |
Add stochastic gradient descent test. | <?php
namespace mcordingley\Regression\Tests;
use mcordingley\Regression\Algorithm\GradientDescent\Stochastic;
use mcordingley\Regression\Algorithm\GradientDescent\Schedule\Adagrad;
use mcordingley\Regression\Algorithm\GradientDescent\Gradient\Linear;
use mcordingley\Regression\Observations;
use PHPUnit_Framework_Tes... | |
Set format by Accept header | <?php
namespace Netlogix\JsonApiOrg\Http\Request;
/*
* This file is part of the Netlogix.JsonApiOrg package.
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use TYPO3\Flow\Annotations as Fl... | |
Add unit tests for LocalizedDate. | <?php
use VotingApp\LocalizedDate;
class LocalizedDateTest extends TestCase
{
/**
* Verify that US-style MM/DD/YYYY dates can be parsed.
* @test
*/
public function testMMDDYYYYDates()
{
$date = new LocalizedDate('1/2/1990', 'US');
$this->assertInstanceOf('VotingApp\Localiz... | |
Add extra validation for vote creation. | <?php
$question = trim($_REQUEST['question']);
if($_REQUEST['action'] == 'Preview Vote')
{
$container = create_container('skeleton.php','vote_create.php');
$container['PreviewVote'] = $question;
$container['Days'] = $_REQUEST['days'];
forward($container);
}
$option = trim($_REQUEST['option']);
if($_REQUEST['action'... | <?php
$question = trim($_REQUEST['question']);
if($_REQUEST['action'] == 'Preview Vote')
{
$container = create_container('skeleton.php','vote_create.php');
$container['PreviewVote'] = $question;
$container['Days'] = $_REQUEST['days'];
forward($container);
}
$option = trim($_REQUEST['option']);
if($_REQUEST['action'... |
Add tax ID validator interface | <?php
/*
* This file is part of the Active Collab Payments project.
*
* (c) A51 doo <info@activecollab.com>. All rights reserved.
*/
declare(strict_types=1);
namespace ActiveCollab\Payments\TaxRates;
interface TaxIdValidatorInterface
{
public function isValid(string $tax_id): bool;
}
| |
Create (feature) test for tags | <?php
namespace Tests\Feature;
use App\User;
use App\Space;
use App\Tag;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class TagTest extends TestCase {
public function testUnauthorizedUserCantEditTag() {
$user = factory(User::class)->c... | |
Add eloquent tenant resolver implementation | <?php namespace Phonebook\Resolvers;
class EloquentTenantResolver implements TenantResolver {
protected $tenant;
protected $config;
public function __construct(Repository $config, Application $app, Request $request)
{
$this->config = $config;
$this->tenant = $app->make($this->conf... | |
Add sort function test suite. | <?php
namespace Mimic\Test;
use PHPUnit_Framework_TestCase;
use Mimic\Functional as F;
/**
* Unit Test for sort Mimic library function.
*
* @since 0.1.0
*/
class SortFuncTest extends PHPUnit_Framework_TestCase {
public function dataProvider() {
return array(
array(false, F\sortable(), array(4, 2, 1, 3), ar... | |
Test the cleanup of old sessions | <?php
namespace Frontend\Modules\Profiles\Tests\Engine;
use Common\WebTestCase;
use DateTime;
use Frontend\Core\Engine\Model as FrontendModel;
use Frontend\Modules\Profiles\Engine\Authentication;
use SpoonDatabase;
final class AuthenticationTest extends WebTestCase
{
public function setUp(): void
{
p... | |
Add a class to support Optimizely X | <?php
namespace GrowthOptimized\OAuth2\Client\Provider;
/**
* Class OptimizelyX
* @package GrowthOptimized\OAuth2\Client\Provider
*/
class OptimizelyX extends Optimizely
{
/**
* Api domain
*
* @var string
*/
protected $apiDomain = 'https://api.optimizely.com/v2';
} | |
Create ATM modal block for modal functionality | <?php
namespace Drupal\adtechmedia\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a 'AtmModal' block.
*
* @Block(
* id = "atm_modal",
* admin_label = @Translation("ATM Modal"),
* )
*/
class AtmModal extends BlockBase {
/**
* {@inheritdoc}
*/
... | |
Add unit test for Status | <?php
namespace Marein\Nchan\Api;
use Marein\Nchan\Api\Model\StatusInformation;
use Marein\Nchan\Exception\AuthenticationRequiredException;
use Marein\Nchan\Exception\NchanException;
use Marein\Nchan\Http\Client;
use Marein\Nchan\Http\Response;
use Marein\Nchan\Http\Url;
use PHPUnit\Framework\TestCase;
class StatusT... | |
Add simple primary key for barcode (easier for ORM) | <?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class AddBarcodeId extends AbstractMigration
{
public function up()
{
$q= "ALTER TABLE barcode DROP PRIMARY KEY,
ADD COLUMN `id` INT(11) unsigned NOT NULL
AUT... | |
Add wide template for Page Attribute Display block | <?php
defined('C5_EXECUTE') or die('Access Denied.');
?>
<div class="row">
<div class="col-xl-10 offset-xl-1">
<?php require dirname(__FILE__) . '/worldskills_content.php'; ?>
</div>
</div>
| |
Set Job type_id to 1 for all jobs | <?php
namespace Application\Migrations;
use SimplyTestable\BaseMigrationsBundle\Migration\BaseMigration,
Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your need!
*/
class Version20130122121234_set_default_Job_type_id extends BaseMigration
{
public function up(Schema $schema)... | |
Check whether functions and class before loading file | <?php
require_once('Classloader.php');
require_once('xmlrpc.inc');
$classLoader = new Infusionsoft_Classloader();
spl_autoload_register(array(&$classLoader, "loadClass"));
require('config.php'); | <?php
require_once('Classloader.php');
if(!function_exists('xmlrpc_encode_entitites') && !class_exists('xmlrpcresp')) {
require_once('xmlrpc.inc');
}
$classLoader = new Infusionsoft_Classloader();
spl_autoload_register(array(&$classLoader, "loadClass"));
require('config.php');
|
Add broken taxonomy type test file | <?php
class Broken_Taxonomy_Type extends Papi_Taxonomy_Type {
/**
* Define our Taxonomy Type meta data.
*
* @return array
*/
public function meta2() {
return [
'id' => 'custom-taxonomy-type-id',
'name' => 'Broken taxonomy',
'description' => 'This is a broken taxonomy',
'templat... | |
Add test for XmlToObject output strategy | <?php
/**
* FurryBear
*
* PHP Version 5.3
*
* @category Congress_API
* @package FurryBear
* @author lobostome <lobostome@local.dev>
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/lobostome/FurryBear
*/
namespace FurryBear\Tests\Output\Strategy;
/**
* Test fo... | |
Add japanese language for feed types | <?php
return [
'regular' => '定時',
'extra' => '随時',
'eqvol' => '地震火山',
'other' => 'その他',
];
| |
Add a RPC Client Processor | <?php
namespace Swarrot\Processor\RPC;
use Psr\Log\LoggerInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Swarrot\Broker\Message;
use Swarrot\Processor\ProcessorInterface;
use Swarrot\Processor\ConfigurableInterface;
use Swarrot\Processor\SleepyInterface;
/**
* Act as a RPC client tha... | |
Copy weapon IDs of SplatNet2 to Splatoon 3's weapon | <?php
/**
* @copyright Copyright (C) 2015-2022 AIZAWA Hina
* @license https://github.com/fetus-hina/stat.ink/blob/master/LICENSE MIT
* @author AIZAWA Hina <hina@fetus.jp>
*/
declare(strict_types=1);
use app\components\db\Migration;
use yii\db\Connection;
use yii\db\Expression;
use yii\db\Query;
final class m220... | |
Add create command for FOSUsers. | <?php
// src/AppBundle/Command/CreateUsersCommand.php
namespace AppBundle\Command;
use AppBundle\Entity\FOSUser;
use Composer\Installer\PackageEvent;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bund... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.