Skip to content

Instantly share code, notes, and snippets.

@alexbowers
Created December 2, 2016 18:54
Show Gist options
  • Save alexbowers/de7fdccf4ae3c1c1ce03d909313ae47c to your computer and use it in GitHub Desktop.
Save alexbowers/de7fdccf4ae3c1c1ce03d909313ae47c to your computer and use it in GitHub Desktop.
<?php
class Collection implements Castable
{
protected $items = [];
public function __construct(array $items = [])
{
$this->items = $items;
}
// ...
}
class AnotherClass
{
public static function DoSomething(Collection $collection)
{
// ...
return $collection->sum();
}
}
// Acceptable Parameters: Collection | array
$another = AnotherClass::DoSomething([1,2,3]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment