Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Write a Twig extension that serves as a simple wrapper around Gregwar's Image library | <?php
require 'vendor/autoload.php';
use Gregwar\Image\Image;
class ImageTwig extends Twig_Extension
{
public function getName()
{
return 'image';
}
public function getFunctions()
{
return array(
new Twig_SimpleFunction('image', array($this, 'image'))
);
}
... | |
Use EventListenerInterface instead of EventListener. | <?php
namespace Crud\Core;
use Cake\Controller\Controller;
use Cake\Core\InstanceConfigTrait;
use Cake\Event\Event;
use Cake\Event\EventListener;
use Crud\Event\Subject;
/**
* Crud Base Class
*
* Implement base methods used in CrudAction and CrudListener classes
*
* Licensed under The MIT License
* For full cop... | <?php
namespace Crud\Core;
use Cake\Controller\Controller;
use Cake\Core\InstanceConfigTrait;
use Cake\Event\Event;
use Cake\Event\EventListenerInterface;
use Crud\Event\Subject;
/**
* Crud Base Class
*
* Implement base methods used in CrudAction and CrudListener classes
*
* Licensed under The MIT License
* For... |
Create a Voice RSS provider | <?php
namespace duncan3dc\Speaker\Providers;
use duncan3dc\Speaker\Exception;
/**
* Convert a string of a text to a spoken word mp3.
*/
class VoiceRssProvider extends AbstractProvider
{
/**
* @var string $language The language to use.
*/
protected $language = "en-gb";
/**
* @var int $sp... | |
Support dynamic return types for PhpStorm IDE | <?php
/*
* This file configures dynamic return type support for factory methods in PhpStorm
*/
namespace PHPSTORM_META {
$STATIC_METHOD_TYPES = [
\TYPO3\Flow\Object\ObjectManagerInterface::get('') => [
'' == '@',
]
];
} | |
Add unit tests for FileSerialiser | <?php
namespace Inanimatt\SiteBuilder\Serialiser;
/**
* Generated by PHPUnit_SkeletonGenerator on 2012-05-28 at 10:24:11.
*/
class FileSerialiserTest extends \PHPUnit_Framework_TestCase
{
/**
* @var FileSerialiser
*/
protected $object;
protected $outputPath;
/**
* Sets up the fix... | |
Fix controller stub. Added a new scaffold for widget. | <?php namespace BnB\ScaffoldTranslation\Classes\Console;
use BnB\ScaffoldTranslation\Classes\Templates\Widget;
use BnB\ScaffoldTranslation\Classes\TranslationScanner;
use Illuminate\Console\Command;
use Lang;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class Cre... | |
Add an extra field to killmails for no apparent reason | <?php
use Phinx\Migration\AbstractMigration;
class KillmailsExtraFieldToDetermineIfUpgraded extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/e... | |
Add - classe para buscar "cores antigas" da tabela 'dados_antigos'. | <?php
namespace Mapeadores;
use Entidades\DadosAntigos;
use Entidades\Tamanhos;
use Entidades\Cores;
/**
* @author Tiago Oliveira de Farias
*/
class CoresAntigas extends DadosAntigos{
public function __construct(\PDO $pdo)
{
parent::__construct($pdo);
}
public function buscar()
{
$stmt = $this->pdo->p... | |
Add hydrator that (de)hydrates the object using public properties | <?php
declare(strict_types=1);
namespace Onion\Framework\Hydrator;
trait PropertyHydrator
{
/**
* @inheritdoc
*/
public function hydrate(array $data)
{
$target = clone $this;
foreach ($data as $name => $value) {
$property = str_replace('_', '', lcfirst(ucwords($name, ... | |
Add DAO fetching all available events and single event by id | <?php
namespace Mila\DAO;
final class eventDAO implements DAOInterface
{
/*
* @var \Doctrine\DBAL\Connection
*/
private $dbCon;
/*
* @param \Doctrine\DBAL\Connection $dbCon
*/
public function __construct($dbCon)
{
$this->dbCon = $dbCon;
}
public function fetch... | |
Add a migration with the pinned field to comments | <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPinnedFieldToComments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('comments',... | |
Create example script demoing the converter | <?php
require_once '..\docx2md.php';
$converter = new Docx2md\Docx2md;
$files = glob('docx/*.docx', GLOB_BRACE);
foreach ($files as $file) {
echo $converter->parseFile($file) . '<br><br>';
} | |
Add missing pluggable interface file. | <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license an... | |
Add single Sign-On feature for services and products. It automatically logs in the users on SolusVM control panel. | <?php
/*
* SolusVM_ServiceSingleSignOn
*
* Perform single sign-on for a given instance of a product/service in this case VPS to the SolusVM control panel
*
* @package SolusVM
* @category WHMCS Provisioning Modules
* @author Trajche Petrov
* @link https://qbit.solutions/
*/
class SolusVM_ServiceSingleSignOn ... | |
Add a PHP cli script to get range file adress from isbn authority | <?php
include('vendor/autoload.php');
echo "Requesting XML ranges file...\n";
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://www.isbn-international.org/?q=bl_proxy/GetRangeInformations', [
'form_params' => [
'format' => 1,
'language' => 'en',
'translatedTexts'... | |
Add Ensure Production Settings command | <?php namespace Mitch\LaravelDoctrine\Console;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Input\InputOption;
class EnsureProductionSettingsCommand extends Command {
protected $name = 'doctrine:ensure-production-settings';
protected $description = 'Verify that Doctrine is properly ... | |
Add test case for Key::deriveFromPassword | <?php
use \ParagonIE\Halite\Key;
/**
* @backupGlobals disabled
* @backupStaticAttributes disabled
*/
class KeyTest extends PHPUnit_Framework_TestCase
{
public function testDerive()
{
$key = Key::deriveFromPassword(
'apple',
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0... | |
Add town step 3 type form | <?php
namespace Listabierta\Bundle\MunicipalesBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints as Assert;
class TownStep3Type extends AbstractType
{
... | |
Add migration for institution configuration options | <?php
namespace Surfnet\StepupMiddleware\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160728074605 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public funct... | |
Fix migration issue related to upgrade from beta5 to master - migration to remove unused login_disabled field | <?php
namespace Oro\Bundle\UserBundle\Migrations\Schema\v1_24;
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
class AddDisableLogin implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $sche... | |
Add the ability to hardware-pair Pico remotes and Caseta dimmers directly, for speed and reliability far beyond what SmartThings will ever be able to offer. | <?php
// Hardware-pairs a Pico remote to a set of Caseta dimmers.
// Useful for bypassing SmartThings' considerable latency and establishing
// instant and reliable Pico-to-Caseta communication.
// Pass a negative number for the caseta ID to remove instead of add.
$pico = intval(@$_REQUEST["pico"]) or emsg('No pico ... | |
Check what is waster $this of self | <?php
/**
* Check what is there overhead when used static call on dynamic methods
*
* @file ThisVsSelf.php
*
* PHP version 5.3.9+
*
* @author Yancharuk Alexander <alex@itvault.info>
* @date 2013-08-04 10:16
* @copyright The BSD 3-Clause License
*/
namespace Tests;
use \Veles\Tools\Timer;
use \Veles\T... | |
Add class to test frontend tags model | <?php
namespace Frontend\Modules\Tags\Tests\Engine;
use Frontend\Core\Engine\Model as FrontendModel;
use Frontend\Modules\Tags\Engine\Model;
use Common\WebTestCase;
final class ModelTest extends WebTestCase
{
public function setUp(): void
{
parent::setUp();
if (!defined('APPLICATION')) {
... | |
Add a tool for checking language files | <?php
if ($argc != 2 || (isset($argv[1]) && in_array($argv[1], array('--help', '-h')))) {
echo "Check language files for missing/redundant keys\n\n";
echo "Usage: {$argv[0]} <lang>\n";
echo "Alternative usage: {$argv[0]} all\n";
exit;
}
chdir('../phpdotnet/phd/data/langs/');
if ($argv[... | |
Support Windows color with ANSICON | <?php
namespace mageekguy\atoum;
use
mageekguy\atoum
;
class cli
{
private static $isTerminal = null;
public function __construct(atoum\adapter $adapter = null)
{
if ($adapter === null)
{
$adapter = new atoum\adapter();
}
if (self::$isTerminal === null)
{
self::$isTerminal = ($adapter->defined(... | <?php
namespace mageekguy\atoum;
use
mageekguy\atoum
;
class cli
{
private static $isTerminal = null;
public function __construct(atoum\adapter $adapter = null)
{
if ($adapter === null)
{
$adapter = new atoum\adapter();
}
if (self::$isTerminal === null)
{
self::$isTerminal = $adapter->defined('... |
Add index to oc_cards to assist with searching large number of rows | <?php
namespace OCA\dav\Migrations;
use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;
/**
* Add index to oc_cards to assist with searching with large numbers of rows
*/
class Version20170519091921 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$pr... | |
Add tests for the error page | <?php
namespace Backend\Modules\Error\Tests\Action;
use Common\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
class IndexTest extends WebTestCase
{
public function testAuthenticationIsNotNeeded(): void
{
$client = static::createClient();
$this->logout($client);
$client->... | |
Add test of required S3 parameters | <?php
/**
* This file is part of the Imbo package
*
* (c) Christer Edvartsen <cogo@starzinger.net>
*
* For the full copyright and license information, please view the LICENSE file that was
* distributed with this source code.
*/
namespace ImboUnitTest\Storage;
use Imbo\Exception\ConfigurationException,
Imb... | |
Add rudimentary unit test for z_mime_content_type. | <?php
/**
* this file contains tests for the uploader
*
* @package test.util
*/
/** required, it is the file under test */
require_once('include/attach.php');
/**
* TestCase for the uploader
*
* @author ken restivo
* @package test.util
*/
class UploadTest extends PHPUnit_Framework_TestCase {
public functi... | |
Standardize save to json php | <?php
$filename = $_SERVER['DOCUMENT_ROOT'] . $_POST['file'];
$decoded = base64_decode($_POST['json']);
$jsonFile = fopen($filename,'w') or die("Unable to open file!");
fwrite($jsonFile,$decoded);
fclose($jsonFile);
echo 'Data Saved';
?> | |
Allow view routes for pages | <?php namespace Anomaly\PagesModule\Page;
use Anomaly\PagesModule\Page\Contract\PageInterface;
use Anomaly\Streams\Platform\Entry\EntryRouter;
/**
* Class PageRouter
*
* @link http://pyrocms.com/
* @author PyroCMS, Inc. <support@pyrocms.com>
* @author Ryan Thompson <ryan@pyrocms.com>
*/
class PageRouter exten... | |
Throw exception if connection fails | <?php
namespace Michaels\Spider\Drivers;
use Exception;
/**
* Exception for broken or refused connection
* @package Michaels\Spider\Drivers
*/
class ConnectionException extends Exception
{
}
| |
Test for SPIRE connector API. | <?php
require_library('connectors/SpireAPI');
class test_connector_spire_api extends SimpletestUnitBase
{
function testSpireAPI()
{
$GLOBALS['arr_taxa']["genus species"] = Array
(
"desc" => "my species",
"objects" => Array
(... | |
Add a sample to create an issue | <?php
include dirname( dirname( __FILE__ ) ) . '/MantisPhpClient.php';
# TODO:
# Set the username
# Set the api token or password
# Set the project name
# Set the url
#
# For information about API tokens, check the following blog post:
# http://blog.mantishub.com/2015/12/21/using-api-tokens-to-access-mantishub/
$mant... | |
Create Moip\Exceptions and class for the 401 exception | <?php
namespace Moip\Exceptions;
/**
* Class AuthException
*
* This exception is thrown when the Moip API returns a 401 http code.
* The error message was extracted from the documentation.
*
* @package Moip\Exceptions
*/
class UnautorizedException extends \RuntimeException
{
public function __construct()
... | |
Add test cases for JsonHelper | <?php
use fproject\amqp\ActivityNoticeSerializer;
use fproject\amqp\JsonHelper;
include_once('TestModel01.php');
include_once('TestModel02.php');
class JsonHelperTest extends PHPUnit_Framework_TestCase
{
private $params = [];
public function testJsonEncodeActivityNotice()
{
$this->params = [
... | |
Add order email attachment download | <?php
/**
* [RO] Descarca un atasament aferent email-ului unei comenzi si informatii relevante despre acesta (https://github.com/celdotro/marketplace/wiki/Descarca-atasamentul-email-ului-comenzii)
* [EN] Downloads an attachment belonging to an order's email and other relevant information regarding the attachment (htt... | |
Add test case for Cast utility | <?php
namespace Buybrain\Buybrain\Util;
use PHPUnit\Framework\TestCase;
class CastTest extends TestCase
{
public function testCastToString()
{
$this->assertEquals('abc', Cast::toString('abc'));
$this->assertEquals('123', Cast::toString(123));
$this->assertEquals(null, Cast::toString(nu... | |
Fix template insertion in twig.form.resources | <?php
/*
* This file is part of the MopaBootstrapBundle.
*
* (c) Philipp A. Mohrenweiser <phiamo@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mopa\Bundle\BootstrapBundle\DependencyInjection\Compiler;
... | <?php
/*
* This file is part of the MopaBootstrapBundle.
*
* (c) Philipp A. Mohrenweiser <phiamo@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mopa\Bundle\BootstrapBundle\DependencyInjection\Compiler;
... |
Fix partner zero playlists file syncs | <?php
require_once(dirname(__FILE__).'/../bootstrap.php');
$playlists = entryPeer::retrieveByPKs(array('_KMCSPL1', '_KMCSPL2'));
foreach($playlists as $playlist)
{
/* @var $playlist entry */
$criteria = new Criteria();
$criteria->add(FileSyncPeer::OBJECT_TYPE, FileSyncObjectType::ENTRY);
$criteria->add(FileSync... | |
Add possible replacement for ContentFilter. | <?php
// Jivoo
// Copyright (c) 2015 Niels Sonnich Poulsen (http://nielssp.dk)
// Licensed under the MIT license.
// See the LICENSE file or http://opensource.org/licenses/MIT for more information.
namespace Jivoo\ActiveModels;
/**
* Mixin for automatically compiling content fields.
*/
class ContentMixin extends Act... | |
Add backend for checking and getting the lastest notification | <?php
# check here
//Notifications which could be shown in the bottom corner of the page, and also dismissed.
//This would require another table with system information which can be marked read? Or something like this. It would be best to have it in the account page.
//Display a header with information? This can be d... | |
Add a custom throttle class | <?php
/**
* Copyright (c) (2017) - Aikar's Minecraft Timings Parser
*
* Written by Aikar <aikar@aikar.co>
* + Contributors (See AUTHORS)
*
* http://aikar.co
* http://starlis.com
*
* @license MIT
*
*/
namespace Starlis\Timings;
use Stiphle\Storage\Apc;
use Stiphle\Throttle\LeakyBucket;
class Timing... | |
Create helper for assertion messages. | <?php
namespace pyd\testkit;
/**
* Store and provide generic failure messages for assertion methods.
*
* <code>
* // AssertionMessage::get() will return the message set by the hasFocus()
* // method
* $this->assertTrue($form->username->hasFocus(), AssertionMessage::get());
* </code>
*
* @author pyd <pierre.yv... | |
Set SplatNet ID for bbass | <?php
/**
* @copyright Copyright (C) 2015-2017 AIZAWA Hina
* @license https://github.com/fetus-hina/stat.ink/blob/master/LICENSE MIT
* @author AIZAWA Hina <hina@bouhime.com>
*/
use app\components\db\Migration;
class m171028_033342_bbass_splatnet extends Migration
{
public function safeUp()
{
$this... | |
Fix defaults of new fields | <?php
use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class FixQbJeId extends AbstractMigration
{
public function change()
{
$table= $this->table('payment', [ 'signed' => false ]);
$table
->changeColumn('qb_je_id', 'string', [ 'limit' => 512, 'default' => '' ])
... | |
Add events.php for table trl | <?php
class Kwc_Basic_Table_Trl_Events extends Kwc_Chained_Trl_Events
{
public function getListeners()
{
$ret = parent::getListeners();
$childModel = Kwc_Abstract::getSetting($this->_class, 'childModel');
$ret[] = array(
'class' => $childModel,
'event' => 'Kwf_Com... | |
Add table seeder for statuses | <?php
class StatusesTableSeeder extends Seeder {
public function run()
{
Status::create([
'title' => 'Open'
]);
Status::create([
'title' => 'In Progress'
]);
Status::create([
'title' => 'On Hold'
]);
Status::create([
'title' => 'Closed'
]);
}
} | |
Add a service manager factory for the translator | <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license an... | |
Install event, resource, feedaggregator plugins. | <?php
use Hubzero\Content\Migration\Base;
/**
* Migration script for enabling digest plugins
* Specifically the event, feedaggregator, and resource plugins
**/
class Migration201603091905401ComNewsletter extends Base
{
/**
* Up
**/
public function up()
{
$elements = array('event','feedaggregator','resourc... | |
Add console cli with basic interactive command | <?php
class CM_Console_Cli extends CM_Cli_Runnable_Abstract {
public function interactive() {
while ('exit' !== ($code = $this->_getInput()->read('php >'))) {
$result = null;
try {
$code = '$result = ' . $code . ';';
if (false !== eval($code)) {
$this->_getOutput()->writeln(print_r($result, true... | |
Add unit test to FDPrivateMessageExtension | <?php
namespace FD\PrivateMessageBundle\Tests\DependencyInjection;
use FD\PrivateMessageBundle\DependencyInjection\FDPrivateMessageExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Class FDPrivateMessageExtensionTest.
*/
class FDPrivateMessageExtensionTest extends \PHPUnit_Framework_Test... | |
Implement unit tests for console ouput | <?php
namespace Neos\Flow\Tests\Unit\Cli;
/*
* This file is part of the Neos.Flow package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* 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... | |
Add comet server for future JTK notification system. | <?php
// Jivoo
// Copyright (c) 2015 Niels Sonnich Poulsen (http://nielssp.dk)
// Licensed under the MIT license.
// See the LICENSE file or http://opensource.org/licenses/MIT for more information.
namespace Jivoo\Jtk\Notifications;
use Jivoo\Snippets\CometSnippet;
use Jivoo\Core\Json;
class NotificatonServer extends... | |
Add validator messages for expired cards | <?php defined('SYSPATH') OR die('No direct script access.');
return array(
'exp_year' => array(
'card_expired' => 'Your card has expired',
),
'exp_month' => array(
'card_expired' => 'Your card has expired',
),
); | |
Add basic test for extracting schemas from a mysql5 database | <?php
/**
* DBSteward unit test for mysql5 extraction errors
*
* @package DBSteward
* @license http://www.opensource.org/licenses/bsd-license.php Simplified BSD License
* @author Austin Hyde <austin109@gmail.com>
*/
require_once 'PHPUnit/Framework/TestCase.php';
require_once __DIR__ . '/../../lib/DBSteward/dbste... | |
Add tool to get OVH credentials | <?php
/**
* Copyright 2013 Stéphane Depierrepont (aka Toorop)
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* or in the "license" f... | |
Add a interface for custom collections classes | <?php
namespace Galahad\LaravelAddressing;
/**
* Interface CollectionInterface
*
* @package Galahad\LaravelAddressing
* @author Junior Grossi <juniorgro@gmail.com>
*/
interface CollectionInterface
{
/**
* Return all the items ready for a <select> HTML element
*
* @return mixed
*/
publ... | |
Add base test case for Transformer | <?php
namespace OpenOrchestra\BaseApi\Tests\Transformer;
use Phake;
/**
* Test TransformerTestCase
*/
abstract class TransformerTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @var \Phake_IMock
*/
protected $transformerManager;
/**
* @var \Phake_IMock
*/
protected $router;... | |
Add unique index constraint for unique indexes. | <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddUniqueIndexes extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $collection) {
$c... | |
Add migration to turn INT columns to STRING columns | <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class StoreCampaignIdAsString extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('signups', f... | |
Add core area layout gray | <?php
defined('C5_EXECUTE') or die("Access Denied.");
$a = $b->getBlockAreaObject();
$container = $formatter->getLayoutContainerHtmlObject();
?>
<div class="ws-layout-gray">
<div class="container">
<?php
foreach ($columns as $column) {
$html = $column->getColumnHtmlObject();
... | |
Upgrade safe setting default quote template | <?php
// created: 2011-09-21 13:26:01
$dictionary['AOS_Quotes']['fields']['template_ddown_c']['default']='31d00d62-8892-7587-4153-4d9c843c2843';
?>
| |
Add Form directory including SocialMediaAggregatorForm class | <?php
/**
* @file
* Contains \Drupal\example\Form\ExampleForm.
*/
namespace Drupal\example\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements an example form.
*/
class SocialMediaAggregatorForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFo... | |
Add artist tagging page (missed from last commit) | <?php
/* GNU FM -- a free network service for sharing your music listening habits
Copyright (C) 2009 Free Software Foundation, 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 default site name setting. | <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddSiteNameToSettings extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::table('settings')->insert([
'key' => 'site_title',
'value' => 'Votin... | |
Delete unused columns from activities table | <?php namespace System\Database\Migrations;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Schema;
/**
* customer_id can be NULL on addresses table
*/
class deleteUnusedColumnsFromActivitiesTable extends Migration
{
public function up()
{
Schema::table('a... | |
Return the current key and value pair from an array and advance the array cursor |
<?php
$foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each($foo);
print_r($bar);
?>
| |
Add a couple of simple PHPUnit tests | <?php
//require_once 'PHPUnit/Framework.php';
require_once 'at.wrapper.php';
use Treffynnon\At\Wrapper as At;
class AtWrapperTest extends PHPUnit_Framework_TestCase {
protected $test_file = '';
public function setUp() {
$this->test_file = tempnam(sys_get_temp_dir(), 'php');
}
public function te... | |
Add new report for daily payment info | <?
require 'scat.php';
head("daily report");
$q= "SELECT DATE_FORMAT(processed, '%Y-%m-%d %a') AS date,
method, cc_type, SUM(amount) amount
FROM payment
WHERE processed > DATE(NOW() - INTERVAL 8 DAY)
GROUP BY date, method, cc_type
ORDER BY date DESC";
$r= $db->query($q)
or die(... | |
Update implementation of UI views to support updated data structure: Server side | <?php
namespace Oro\Bundle\CalendarBundle\Migrations\Data\ORM;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Oro\Bundle\CalendarBundle\Entity\CalendarEvent;
use Oro\Bundle\EntityExtendBundle\Entity\AbstractEnumValue;
use Oro\Bundle\EntityExtendBundle\Entity\Repo... | |
Make it possible to upload files to Company Images | <?php
class Infusionsoft_FileServiceBase extends Infusionsoft_Service{
public static function getFile($fileId, Infusionsoft_App $app = null){
$params = array(
(int) $fileId
);
return parent::send($app, "FileService.getFile", $params);
}
public static fun... | <?php
class Infusionsoft_FileServiceBase extends Infusionsoft_Service{
public static function getFile($fileId, Infusionsoft_App $app = null){
$params = array(
(int) $fileId
);
return parent::send($app, "FileService.getFile", $params);
}
public static function getDo... |
Add back to website spec. | <?php
namespace spec\App\Http\Handlers;
use App\Http\Handlers\BackToWebsite;
use Illuminate\Container\Container;
use Orchestra\Contracts\Foundation\Foundation;
use Orchestra\Widget\Handlers\Menu;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class BackToWebsiteSpec extends ObjectBehavior
{
function let(Cont... | |
Add a test for pagination | <?php
namespace OpenCFP\Test\Domain\Services;
use OpenCFP\Domain\Services\Pagination;
use OpenCFP\Test\BaseTestCase;
use Pagerfanta\Pagerfanta;
class PaginationTest extends BaseTestCase
{
/**
* @var Pagination
*/
private $pagination;
public function setUp()
{
parent::setUp();
... | |
Implement yaml loader for the configuration file | <?php
namespace PhpAbac\Loader;
use Symfony\Component\Config\Loader\FileLoader;
use Symfony\Component\Yaml\Yaml;
class YamlAbacLoader extends FileLoader
{
public function load($resource, $type = null)
{
return Yaml::parse(file_get_contents($resource));
}
public function supports($resource, $... | |
Add STA Plaza to meeting room jump list | <div class="btn-group btn-group-justified">
<a class="btn btn-default" href="#downtown">Downtown</a>
<a class="btn btn-default" href="#east-side">East Side</a>
<a class="btn btn-default" href="#hillyard">Hillyard</a>
<a class="btn btn-default" href="#indian-trail">Indian Trail</a>
<a class="btn btn-default" href="... | <div class="btn-group btn-group-justified">
<a class="btn btn-default" href="#sta-plaza">STA Plaza</a>
<a class="btn btn-default" href="#east-side">East Side</a>
<a class="btn btn-default" href="#hillyard">Hillyard</a>
<a class="btn btn-default" href="#indian-trail">Indian Trail</a>
<a class="btn btn-default" href... |
Add top memes display controller | <?php
class TopController extends \BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getIndex()
{
$memes = Meme::all();
//Get all memes that have more than 10 votes
foreach($memes as $meme){
if($meme->codes()->whereNotNull... | |
Write specs for the ElasticsearchExecutor | <?php
namespace spec\RulerZ\Executor;
use Elasticsearch\Client;
use PhpSpec\ObjectBehavior;
use RulerZ\Executor\Executor;
class ElasticsearchExecutorSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('RulerZ\Executor\ElasticsearchExecutor');
}
function it_s... | |
Add parse function for optional fields to avoid accessing non existent properties | <?php
/*
* This file is part of the easypay-php package.
*
* (c) Samuel Gordalina <https://github.com/gordalina/easypay-php>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gordalina\Easypay\Response;
abstract class Ab... | |
Revert "removing an accidently added custom" | <?php
//WARNING: The contents of this file are auto-generated
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms ... | |
Add test coverage for LegacyEmptyPass. | <?php
/*
* This file is part of Psy Shell
*
* (c) 2012-2014 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Test\CodeCleaner;
use Psy\CodeCleaner\LegacyEmptyPass;
class LegacyEmptyPassTest extends C... | |
Add a base Eloquent Repository | <?php namespace Exolnet\Database\Eloquent;
use Exolnet\Core\Exceptions\RepositoryException;
use Exolnet\Database\Repository\Repository;
use Illuminate\Database\Eloquent\Model;
class EloquentRepository implements Repository
{
/**
* @var string
*/
protected $model;
/**
* @return \Illuminate\Database\Eloquent\... | |
Update files, Alura, PHP e Orientação a Objetos, Aula 5 | <?php
require "classe/Produto.php";
$livro = new Produto;
$livro->setNome("Livro da casa do codigo");
$livro->setPreco(10);
$livro2 = new Produto;
$livro2->setNome("Livro da casa do codigo");
$livro2->setPreco(10);
$livro2 = $livro;
if($livro === $livro2) {
echo "sao iguais";
} else {
echo "sao diferentes";
}
?... | |
Add example for mysql unix socket. | <?php
go(function(){
$db = new Swoole\Coroutine\Mysql;
$server = [
'host' => 'unix:/tmp/mysql.sock',
'user' => 'root',
'password' => 'root',
'database' => 'test'
];
$db->connect($server);
$stmt = $db->prepare('SELECT * FROM `user` WHERE id=?');
$ret = $st... | |
Add test for wp core is-installed when WordPress is not installed | <?php
class CoreTest extends PHPUnit_Framework_TestCase {
public function testIsInstalledExitsWith1IfWordPressNotInstalled() {
$temp_dir = self::create_temporary_directory();
$result = self::run_wp_cli("core is-installed --path=$temp_dir");
$this->assertEquals(1, $result->return_code);
}... | |
Create tests for the javascript | <?php namespace spec\CeesVanEgmond\Minify\Providers;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use org\bovigo\vfs\vfsStream;
class JavaScriptSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('CeesVanEgmond\Minify\Providers\JavaScript');
}
function i... | |
Add a view helper to get a reverse URL from a route | <?php
/**
* @package Neolao\Site\Helper\View
*/
namespace Neolao\Site\Helper\View;
use \Neolao\Logger;
use \Neolao\Site\Helper\View\AbstractHelper;
use \Neolao\Site\Request;
use \Neolao\Site;
/**
* Helper to get the reverse URL of a route
*/
class RouteReverseHelper extends AbstractHelper
{
/**
* Get the... | |
Add the portuguese municipalities table seeder | <?php
/*
* This file is part of Bens Penhorados, an undergraduate capstone project.
*
* (c) Fábio Santos <ffsantos92@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Illuminate\Database\Seeder;
/**
* This is the p... | |
Create form to open account | <?php
namespace HCLabs\Bills\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class OpenAccountType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInter... | |
Implement Aura package types: package and include | <?php
namespace Composer\Installers;
class AuraInstaller extends BaseInstaller
{
protected $locations = array(
'package' => 'package/{$name}/',
'include' => 'include/{$name}/',
);
}
| |
Prepare migration inserting record_status columns | <?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class InsertStatusColumns extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(Schema::hasTable('assessmen... | |
Add locale detection for testing. | <?php
/**
* @license http://opensource.org/licenses/MIT MIT
*/
// The locale on `setlocale()` function may accepted different value depend on PHP version.
// Read more at https://stackoverflow.com/a/40963241/128761
// The process below will be test what locale that your server will be accepted.
// Set you possibi... | |
Add small filter for filtering out other than .xml-files | <?php
namespace PIKI\MARCXML\Iterator;
use FilterIterator;
class XmlFilter extends FilterIterator
{
public function accept() : bool
{
$current = parent::current();
if(preg_match("/\.xml$/i", $current))
return true;
return false;
}
}
| |
Add an abstract service provider | <?php
/**
* @author TheHostingTool Group
* @version 2.0.0
* @package thehostingtool/core
* @license MIT
*/
namespace TheHostingTool\Kernel;
use Illuminate\Support\ServiceProvider;
abstract class AbstractServiceProvider extends ServiceProvider
{
/**
* @var Application
*/
protected $ap... | |
Add class to handle YAML import input file | <?php
namespace Bolt\Database\Migration\Input;
use Bolt\Database\Migration\Import;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;
/**
* YAML import file
*
* @author Gawain Lynch <gawain.lynch@gmail.com>
*/
class YamlFile imp... | |
Add a hacky override for add_filter so we can test the Hooks trait | <?php
namespace JPB\WP\Dev {
function add_filter( $hook, $callback, $priority = 10, $argCount = 1 ) {
return \add_filter( $hook, $callback, $priority, $argCount );
}
}
| |
Add transformation for applying ICC profiles | <?php
/**
* This file is part of the Imbo package
*
* (c) Christer Edvartsen <cogo@starzinger.net>
*
* For the full copyright and license information, please view the LICENSE file that was
* distributed with this source code.
*/
namespace Imbo\Image\Transformation;
use Imbo\Exception\ConfigurationException;
us... | |
Refactor dispatching events after persisting and updating | <?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Component\Promotion\Event;
class CatalogPromotionCreated
{... | |
Add simple REST controller (GET only) for parameters | <?php
namespace Wanjee\Shuwee\ConfigBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation... | |
Add example for get Venues. | <?php
$companyId = 0; // Company ID
$staffId = 0; //Staff ID
$staffSecret = ''; // Staff API Key
$signer = new \Kobas\Auth\Signer($companyId, $staffId, $staffSecret);
$client = new \Kobas\Client($signer);
$venues = $client->get('data/venue'); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.