This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:yakkety | |
RUN apt-get update && apt-get install -y php7.0 php-mbstring php-dom composer zip | |
RUN php -v | |
RUN echo '{"require":{"imbo/behat-api-extension":"^1.0"}}' > composer.json | |
RUN composer install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"value": "foobarbaz", | |
"markup": [ | |
{ | |
"type": "style:em", | |
"offset": 0, | |
"length": 9 | |
}, | |
{ | |
"type": "style:em", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FeatureContext implements Behat\Behat\Context\ContextInterface { | |
/** | |
* @var array | |
*/ | |
private $articles = []; | |
/** | |
* @var array | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Behat\Testwork\Hook\Scope\BeforeSuiteScope; | |
class FeatureContext { | |
/** | |
* @BeforeSuite | |
*/ | |
static public function setup(BeforeSuiteScope $scope) { | |
var_dump($scope->getSuite()->getSettings()['foo']); // string(3) "bar" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__.'/../vendor/autoload.php'; | |
$app = new Silex\Application(); | |
function handler($a, $b = null, $c = null) { | |
// ... | |
} | |
$app->get('/get/{a}', 'handler'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Silex\Application, | |
Symfony\Component\HttpFoundation\Request; | |
$app->before(function(Request $request, Application $app) { | |
if (($request->isMethod('POST') || $request->isMethod('PUT')) && strpos($request->headers->get('Content-Type'), 'application/json') === 0) { | |
$request->request->set('data', json_decode($request->getContent(), true) ?: []); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use MongoDB\Model\BSONArray, | |
MongoDB\Model\BSONDocument; | |
var_dump( | |
json_encode(['values' => [1, 2]]), | |
json_encode((new BSONDocument(['values' => new BSONArray([1, 2])]))->getArrayCopy()) | |
); | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UrlFriendly { | |
public function format($string) { | |
$translate = array( | |
'Æ' => 'ae', 'Ø' => 'oe', 'Å' => 'aa', 'æ' => 'ae', 'ø' => 'oe', | |
'å' => 'aa', 'é' => 'e', 'è' => 'e', 'à' => 'a', 'ä' => 'a', | |
'É' => 'e', 'È' => 'e', 'ö' => 'o', 'Ö' => 'o', 'õ' => 'o', | |
'Õ' => 'o' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$code = '7090037170053'; | |
$renderer = Zend\Barcode\Barcode::factory( | |
"EAN-13", | |
"image", | |
array( | |
"text" => $code, // substr($code, 0, -1) seems to work, as the checksum then is added automagically | |
"withChecksum" => true, // true / false does not seem to matter | |
), array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.image.find().forEach( | |
function (elem) { | |
db.image.update( | |
{ _id: elem._id }, | |
{ $set: { originalChecksum: elem.checksum }} | |
); | |
} | |
) |