Skip to content

Instantly share code, notes, and snippets.

<?php
/**
*
* This file is part of Atlas for PHP.
*
* @license http://opensource.org/licenses/mit-license.php MIT
*
*/
declare(strict_types=1);
// given that you have created UserMapper and AddressMapper,
// and set up a 1:1 relationship from UserMapper to AddressMapper named 'address':
$atlas
->select(UserMapper::CLASS) // "FROM user"
->joinWith('address') // the name of the relationship field
->cols([
'user.id AS id',
'user.name AS name',
'address.id AS address_id', // aliased using the relationship field name
<?php
class DiscussionRepository
{
public function __construct(DiscussionMapper $mapper) {...}
public function fetchDiscussion($id)
{
$record = $this->mapper->select(['discussion_id' => $id])
->with(['author']);
return $this->newDiscussion($record);
$ composer require radar/adr 1.x
$ rm -rf vendor/composer/ vendor/container-interop/ vendor/psr/
$ phploc --names-exclude="*Test.php" .
phploc 3.0.1 by Sebastian Bergmann.
Directories 31
Files 121
Size
Lines of Code (LOC) 9390
@pmjones
pmjones / gist:12c6e54d9941c162bedfe57d346ef43e
Created January 10, 2017 17:09
Aura web project v2 phploc
$ composer create-project aura/web-project
$ cd web-project
$ rm -rf vendor/composer/ vendor/monolog/ vendor/psr/
$ phploc --names-exclude="*Test.php" .
phploc 3.0.1 by Sebastian Bergmann.
Directories 29
Files 131
Size
@pmjones
pmjones / gist:20109b503a4636fc58046382e7dece75
Created January 10, 2017 16:23
Laravel Complexity Over Time
Per convo at <https://medium.com/@taylorotwell/measuring-code-complexity-64356da605f9> and <https://www.reddit.com/r/PHP/comments/5mycc5/framework_code_complexity_comparison/>.
Ran `phploc` against different branches of <https://github.com/laravel/framework/tree/5.4/src/Illuminate>.
# Size
## 4.0
Directories 90
Files 430
@pmjones
pmjones / gist:6eb6a4f108aac0ea7456a6cbc576fbb1
Created December 26, 2016 15:22
vendor/package counts from packagist
24118 vendors have 1 packages.
7316 vendors have 2 packages.
3496 vendors have 3 packages.
1987 vendors have 4 packages.
1259 vendors have 5 packages.
889 vendors have 6 packages.
654 vendors have 7 packages.
492 vendors have 8 packages.
405 vendors have 9 packages.
307 vendors have 10 packages.
<?php
// add to the end of FactoryTest
public function testSetterCallable()
{
$this->factory->setter['Aura\Di\FakeChildClass']['setFake'] = function () {
return 'OOPS';
};
$object = $this->factory->newInstance('Aura\Di\FakeChildClass');
$actual = $object->getFake();
<?php
$di = $app->getContainer();
// -----------------------------------------------------------------------------
// Service providers
// -----------------------------------------------------------------------------
// Twig
$di->set('view', function () use ($di) {
$settings = $di->get('settings');
<?php
class BlogFilter
{
protected $messages = array();
public function forUpdate(BlogPost $post)
{
$this->messages = array();
if (! trim($post->title)) {