repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yiisoft/yii2-debug
src/components/search/Filter.php
Filter.addMatcher
public function addMatcher($name, MatcherInterface $rule) { if ($rule->hasValue()) { $this->rules[$name][] = $rule; } }
php
public function addMatcher($name, MatcherInterface $rule) { if ($rule->hasValue()) { $this->rules[$name][] = $rule; } }
[ "public", "function", "addMatcher", "(", "$", "name", ",", "MatcherInterface", "$", "rule", ")", "{", "if", "(", "$", "rule", "->", "hasValue", "(", ")", ")", "{", "$", "this", "->", "rules", "[", "$", "name", "]", "[", "]", "=", "$", "rule", ";"...
Adds data filtering rule. @param string $name attribute name @param MatcherInterface $rule
[ "Adds", "data", "filtering", "rule", "." ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/components/search/Filter.php#L33-L38
yiisoft/yii2-debug
src/components/search/Filter.php
Filter.filter
public function filter(array $data) { $filtered = []; foreach ($data as $row) { if ($this->passesFilter($row)) { $filtered[] = $row; } } return $filtered; }
php
public function filter(array $data) { $filtered = []; foreach ($data as $row) { if ($this->passesFilter($row)) { $filtered[] = $row; } } return $filtered; }
[ "public", "function", "filter", "(", "array", "$", "data", ")", "{", "$", "filtered", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "if", "(", "$", "this", "->", "passesFilter", "(", "$", "row", ")", ")", "{", "$"...
Applies filter on a given array and returns filtered data. @param array $data data to filter @return array filtered data
[ "Applies", "filter", "on", "a", "given", "array", "and", "returns", "filtered", "data", "." ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/components/search/Filter.php#L46-L57
yiisoft/yii2-debug
src/components/search/Filter.php
Filter.passesFilter
private function passesFilter(array $row) { foreach ($row as $name => $value) { if (isset($this->rules[$name])) { // check all rules for a given attribute foreach ($this->rules[$name] as $rule) { /* @var $rule MatcherInterface */ ...
php
private function passesFilter(array $row) { foreach ($row as $name => $value) { if (isset($this->rules[$name])) { // check all rules for a given attribute foreach ($this->rules[$name] as $rule) { /* @var $rule MatcherInterface */ ...
[ "private", "function", "passesFilter", "(", "array", "$", "row", ")", "{", "foreach", "(", "$", "row", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "rules", "[", "$", "name", "]", ")", ")", "{", "...
Checks if the given data satisfies filters. @param array $row data @return bool if data passed filtering
[ "Checks", "if", "the", "given", "data", "satisfies", "filters", "." ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/components/search/Filter.php#L65-L80
yiisoft/yii2-debug
src/panels/ConfigPanel.php
ConfigPanel.getExtensions
public function getExtensions() { $data = []; foreach ($this->data['extensions'] as $extension) { $data[$extension['name']] = $extension['version']; } ksort($data); return $data; }
php
public function getExtensions() { $data = []; foreach ($this->data['extensions'] as $extension) { $data[$extension['name']] = $extension['version']; } ksort($data); return $data; }
[ "public", "function", "getExtensions", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'extensions'", "]", "as", "$", "extension", ")", "{", "$", "data", "[", "$", "extension", "[", "'name'", "]", "]...
Returns data about extensions @return array
[ "Returns", "data", "about", "extensions" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/panels/ConfigPanel.php#L53-L62
yiisoft/yii2-debug
src/panels/ConfigPanel.php
ConfigPanel.getPhpInfo
public function getPhpInfo() { ob_start(); phpinfo(); $pinfo = ob_get_contents(); ob_end_clean(); $phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo); $phpinfo = str_replace('<table', '<div class="table-responsive"><table class="table tabl...
php
public function getPhpInfo() { ob_start(); phpinfo(); $pinfo = ob_get_contents(); ob_end_clean(); $phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo); $phpinfo = str_replace('<table', '<div class="table-responsive"><table class="table tabl...
[ "public", "function", "getPhpInfo", "(", ")", "{", "ob_start", "(", ")", ";", "phpinfo", "(", ")", ";", "$", "pinfo", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "$", "phpinfo", "=", "preg_replace", "(", "'%^.*<body>(.*)</body>.*$...
Returns the BODY contents of the phpinfo() output @return array
[ "Returns", "the", "BODY", "contents", "of", "the", "phpinfo", "()", "output" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/panels/ConfigPanel.php#L69-L82
yiisoft/yii2-debug
src/panels/ConfigPanel.php
ConfigPanel.save
public function save() { return [ 'phpVersion' => PHP_VERSION, 'yiiVersion' => Yii::getVersion(), 'application' => [ 'yii' => Yii::getVersion(), 'name' => Yii::$app->name, 'version' => Yii::$app->version, 'la...
php
public function save() { return [ 'phpVersion' => PHP_VERSION, 'yiiVersion' => Yii::getVersion(), 'application' => [ 'yii' => Yii::getVersion(), 'name' => Yii::$app->name, 'version' => Yii::$app->version, 'la...
[ "public", "function", "save", "(", ")", "{", "return", "[", "'phpVersion'", "=>", "PHP_VERSION", ",", "'yiiVersion'", "=>", "Yii", "::", "getVersion", "(", ")", ",", "'application'", "=>", "[", "'yii'", "=>", "Yii", "::", "getVersion", "(", ")", ",", "'n...
{@inheritdoc}
[ "{" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/panels/ConfigPanel.php#L87-L111
yiisoft/yii2-debug
src/FlattenException.php
FlattenException.getTraceAsString
public function getTraceAsString() { $remove = "Stack trace:\n"; $len = strpos($this->_toString, $remove); if ($len === false) { return ''; } return substr($this->_toString, $len + strlen($remove)); }
php
public function getTraceAsString() { $remove = "Stack trace:\n"; $len = strpos($this->_toString, $remove); if ($len === false) { return ''; } return substr($this->_toString, $len + strlen($remove)); }
[ "public", "function", "getTraceAsString", "(", ")", "{", "$", "remove", "=", "\"Stack trace:\\n\"", ";", "$", "len", "=", "strpos", "(", "$", "this", "->", "_toString", ",", "$", "remove", ")", ";", "if", "(", "$", "len", "===", "false", ")", "{", "r...
Gets the stack trace as a string @return string the Exception stack trace as a string.
[ "Gets", "the", "stack", "trace", "as", "a", "string" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/FlattenException.php#L134-L142
yiisoft/yii2-debug
src/FlattenException.php
FlattenException.flattenArgs
private function flattenArgs($args, $level = 0, &$count = 0) { $result = []; foreach ($args as $key => $value) { if (++$count > 10000) { return ['array', '*SKIPPED over 10000 entries*']; } if ($value instanceof \__PHP_Incomplete_Class) { ...
php
private function flattenArgs($args, $level = 0, &$count = 0) { $result = []; foreach ($args as $key => $value) { if (++$count > 10000) { return ['array', '*SKIPPED over 10000 entries*']; } if ($value instanceof \__PHP_Incomplete_Class) { ...
[ "private", "function", "flattenArgs", "(", "$", "args", ",", "$", "level", "=", "0", ",", "&", "$", "count", "=", "0", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "value", ")", "{", "...
Allows you to sterilize the Exception trace arguments @param array $args @param int $level recursion level @param int $count number of records counter @return array arguments tracing.
[ "Allows", "you", "to", "sterilize", "the", "Exception", "trace", "arguments" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/FlattenException.php#L252-L286
yiisoft/yii2-debug
src/panels/ProfilingPanel.php
ProfilingPanel.getSummary
public function getSummary() { return Yii::$app->view->render('panels/profile/summary', [ 'memory' => sprintf('%.3f MB', $this->data['memory'] / 1048576), 'time' => number_format($this->data['time'] * 1000) . ' ms', 'panel' => $this ]); }
php
public function getSummary() { return Yii::$app->view->render('panels/profile/summary', [ 'memory' => sprintf('%.3f MB', $this->data['memory'] / 1048576), 'time' => number_format($this->data['time'] * 1000) . ' ms', 'panel' => $this ]); }
[ "public", "function", "getSummary", "(", ")", "{", "return", "Yii", "::", "$", "app", "->", "view", "->", "render", "(", "'panels/profile/summary'", ",", "[", "'memory'", "=>", "sprintf", "(", "'%.3f MB'", ",", "$", "this", "->", "data", "[", "'memory'", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/panels/ProfilingPanel.php#L40-L47
yiisoft/yii2-debug
src/panels/ProfilingPanel.php
ProfilingPanel.save
public function save() { $target = $this->module->logTarget; $messages = $target->filterMessages($target->messages, Logger::LEVEL_PROFILE); return [ 'memory' => memory_get_peak_usage(), 'time' => microtime(true) - YII_BEGIN_TIME, 'messages' => $messages, ...
php
public function save() { $target = $this->module->logTarget; $messages = $target->filterMessages($target->messages, Logger::LEVEL_PROFILE); return [ 'memory' => memory_get_peak_usage(), 'time' => microtime(true) - YII_BEGIN_TIME, 'messages' => $messages, ...
[ "public", "function", "save", "(", ")", "{", "$", "target", "=", "$", "this", "->", "module", "->", "logTarget", ";", "$", "messages", "=", "$", "target", "->", "filterMessages", "(", "$", "target", "->", "messages", ",", "Logger", "::", "LEVEL_PROFILE",...
{@inheritdoc}
[ "{" ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/panels/ProfilingPanel.php#L69-L78
yiisoft/yii2-debug
src/panels/ProfilingPanel.php
ProfilingPanel.getModels
protected function getModels() { if ($this->_models === null) { $this->_models = []; $timings = Yii::getLogger()->calculateTimings(isset($this->data['messages']) ? $this->data['messages'] : []); foreach ($timings as $seq => $profileTiming) { $this->_model...
php
protected function getModels() { if ($this->_models === null) { $this->_models = []; $timings = Yii::getLogger()->calculateTimings(isset($this->data['messages']) ? $this->data['messages'] : []); foreach ($timings as $seq => $profileTiming) { $this->_model...
[ "protected", "function", "getModels", "(", ")", "{", "if", "(", "$", "this", "->", "_models", "===", "null", ")", "{", "$", "this", "->", "_models", "=", "[", "]", ";", "$", "timings", "=", "Yii", "::", "getLogger", "(", ")", "->", "calculateTimings"...
Returns array of profiling models that can be used in a data provider. @return array models
[ "Returns", "array", "of", "profiling", "models", "that", "can", "be", "used", "in", "a", "data", "provider", "." ]
train
https://github.com/yiisoft/yii2-debug/blob/5d4020c5734cbfaa686afe4ddf438bd5ee51ee53/src/panels/ProfilingPanel.php#L84-L103
yabhq/laravel-scout-mysql-driver
src/Providers/MySQLScoutServiceProvider.php
MySQLScoutServiceProvider.boot
public function boot() { if ($this->app->runningInConsole()) { $this->commands([ ManageIndexes::class, ]); } $this->app->make(EngineManager::class)->extend('mysql', function () { return new MySQLEngine(app(ModeContainer::class)); }...
php
public function boot() { if ($this->app->runningInConsole()) { $this->commands([ ManageIndexes::class, ]); } $this->app->make(EngineManager::class)->extend('mysql', function () { return new MySQLEngine(app(ModeContainer::class)); }...
[ "public", "function", "boot", "(", ")", "{", "if", "(", "$", "this", "->", "app", "->", "runningInConsole", "(", ")", ")", "{", "$", "this", "->", "commands", "(", "[", "ManageIndexes", "::", "class", ",", "]", ")", ";", "}", "$", "this", "->", "...
Bootstrap the application services.
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/yabhq/laravel-scout-mysql-driver/blob/9212a5068e8e6be4d741e6fb7e2191eac632a3be/src/Providers/MySQLScoutServiceProvider.php#L18-L29
yabhq/laravel-scout-mysql-driver
src/Providers/MySQLScoutServiceProvider.php
MySQLScoutServiceProvider.register
public function register() { $this->app->singleton(ModelService::class, function ($app) { return new ModelService(); }); $this->app->singleton(IndexService::class, function ($app) { return new IndexService($app->make(ModelService::class)); }); $this-...
php
public function register() { $this->app->singleton(ModelService::class, function ($app) { return new ModelService(); }); $this->app->singleton(IndexService::class, function ($app) { return new IndexService($app->make(ModelService::class)); }); $this-...
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "ModelService", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "ModelService", "(", ")", ";", "}", ")", ";", "$", "this", ...
Register the application services.
[ "Register", "the", "application", "services", "." ]
train
https://github.com/yabhq/laravel-scout-mysql-driver/blob/9212a5068e8e6be4d741e6fb7e2191eac632a3be/src/Providers/MySQLScoutServiceProvider.php#L34-L51
yabhq/laravel-scout-mysql-driver
src/Commands/ManageIndexes.php
ManageIndexes.handle
public function handle(Dispatcher $events) { $events->listen(Events\ModelIndexCreated::class, function ($event) { $this->comment("Index '$event->indexName' created with fields: $event->indexFields"); }); $events->listen(Events\ModelIndexUpdated::class, function ($event) { ...
php
public function handle(Dispatcher $events) { $events->listen(Events\ModelIndexCreated::class, function ($event) { $this->comment("Index '$event->indexName' created with fields: $event->indexFields"); }); $events->listen(Events\ModelIndexUpdated::class, function ($event) { ...
[ "public", "function", "handle", "(", "Dispatcher", "$", "events", ")", "{", "$", "events", "->", "listen", "(", "Events", "\\", "ModelIndexCreated", "::", "class", ",", "function", "(", "$", "event", ")", "{", "$", "this", "->", "comment", "(", "\"Index ...
Execute the console command. @param Dispatcher $events @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/yabhq/laravel-scout-mysql-driver/blob/9212a5068e8e6be4d741e6fb7e2191eac632a3be/src/Commands/ManageIndexes.php#L46-L77
yabhq/laravel-scout-mysql-driver
src/Engines/MySQLEngine.php
MySQLEngine.search
public function search(Builder $builder) { $result = []; if ($this->shouldNotRun($builder)) { $result['results'] = Collection::make(); $result['count'] = 0; return $result; } $mode = $this->shouldUseFallback($builder) ? $this->fallbackMode : $th...
php
public function search(Builder $builder) { $result = []; if ($this->shouldNotRun($builder)) { $result['results'] = Collection::make(); $result['count'] = 0; return $result; } $mode = $this->shouldUseFallback($builder) ? $this->fallbackMode : $th...
[ "public", "function", "search", "(", "Builder", "$", "builder", ")", "{", "$", "result", "=", "[", "]", ";", "if", "(", "$", "this", "->", "shouldNotRun", "(", "$", "builder", ")", ")", "{", "$", "result", "[", "'results'", "]", "=", "Collection", ...
Perform the given search on the engine. @param Builder $builder @return mixed
[ "Perform", "the", "given", "search", "on", "the", "engine", "." ]
train
https://github.com/yabhq/laravel-scout-mysql-driver/blob/9212a5068e8e6be4d741e6fb7e2191eac632a3be/src/Engines/MySQLEngine.php#L50-L92
yabhq/laravel-scout-mysql-driver
src/Engines/MySQLEngine.php
MySQLEngine.paginate
public function paginate(Builder $builder, $perPage, $page) { $builder->limit = $perPage; $builder->offset = ($perPage * $page) - $perPage; return $this->search($builder); }
php
public function paginate(Builder $builder, $perPage, $page) { $builder->limit = $perPage; $builder->offset = ($perPage * $page) - $perPage; return $this->search($builder); }
[ "public", "function", "paginate", "(", "Builder", "$", "builder", ",", "$", "perPage", ",", "$", "page", ")", "{", "$", "builder", "->", "limit", "=", "$", "perPage", ";", "$", "builder", "->", "offset", "=", "(", "$", "perPage", "*", "$", "page", ...
Perform the given search on the engine. @param Builder $builder @param int $perPage @param int $page @return mixed
[ "Perform", "the", "given", "search", "on", "the", "engine", "." ]
train
https://github.com/yabhq/laravel-scout-mysql-driver/blob/9212a5068e8e6be4d741e6fb7e2191eac632a3be/src/Engines/MySQLEngine.php#L103-L109
Edujugon/PushNotification
src/Fcm.php
Fcm.sendByTopic
public function sendByTopic($topic, $message, $isCondition = false) { $headers = $this->addRequestHeaders(); $data = $this->buildData($topic, $message, $isCondition); try { $result = $this->client->post( $this->url, [ 'headers'...
php
public function sendByTopic($topic, $message, $isCondition = false) { $headers = $this->addRequestHeaders(); $data = $this->buildData($topic, $message, $isCondition); try { $result = $this->client->post( $this->url, [ 'headers'...
[ "public", "function", "sendByTopic", "(", "$", "topic", ",", "$", "message", ",", "$", "isCondition", "=", "false", ")", "{", "$", "headers", "=", "$", "this", "->", "addRequestHeaders", "(", ")", ";", "$", "data", "=", "$", "this", "->", "buildData", ...
Send notification by topic. if isCondition is true, $topic will be treated as an expression @param $topic @param $message @param bool $isCondition @return object
[ "Send", "notification", "by", "topic", ".", "if", "isCondition", "is", "true", "$topic", "will", "be", "treated", "as", "an", "expression" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Fcm.php#L31-L57
Edujugon/PushNotification
src/Fcm.php
Fcm.buildData
protected function buildData($topic, $message, $isCondition) { $condition = $isCondition ? ['condition' => $topic] : ['to' => '/topics/' . $topic]; return array_merge($condition, $this->buildMessage($message)); }
php
protected function buildData($topic, $message, $isCondition) { $condition = $isCondition ? ['condition' => $topic] : ['to' => '/topics/' . $topic]; return array_merge($condition, $this->buildMessage($message)); }
[ "protected", "function", "buildData", "(", "$", "topic", ",", "$", "message", ",", "$", "isCondition", ")", "{", "$", "condition", "=", "$", "isCondition", "?", "[", "'condition'", "=>", "$", "topic", "]", ":", "[", "'to'", "=>", "'/topics/'", ".", "$"...
Prepare the data to be sent @param $topic @param $message @param $isCondition @return array
[ "Prepare", "the", "data", "to", "be", "sent" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Fcm.php#L67-L72
Edujugon/PushNotification
src/PushService.php
PushService.initializeConfig
public function initializeConfig($service) { if (function_exists('config_path') && file_exists(config_path('pushnotification.php')) && function_exists('app') ) { $configuration = app('config')->get('pushnotification'); } else { $configuration =...
php
public function initializeConfig($service) { if (function_exists('config_path') && file_exists(config_path('pushnotification.php')) && function_exists('app') ) { $configuration = app('config')->get('pushnotification'); } else { $configuration =...
[ "public", "function", "initializeConfig", "(", "$", "service", ")", "{", "if", "(", "function_exists", "(", "'config_path'", ")", "&&", "file_exists", "(", "config_path", "(", "'pushnotification.php'", ")", ")", "&&", "function_exists", "(", "'app'", ")", ")", ...
Initialize the configuration for the chosen push service // gcm,etc.. @param $service @throws PushNotificationException @return mixed
[ "Initialize", "the", "configuration", "for", "the", "chosen", "push", "service", "//", "gcm", "etc", ".." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/PushService.php#L64-L79
Edujugon/PushNotification
src/Providers/PushNotificationServiceProvider.php
PushNotificationServiceProvider.boot
public function boot() { $config_path = function_exists('config_path') ? config_path('pushnotification.php') : 'pushnotification.php'; $this->publishes([ __DIR__.'/../Config/config.php' => $config_path, __DIR__.'/../Config/iosCertificates' => config_path('iosCertificates/') ...
php
public function boot() { $config_path = function_exists('config_path') ? config_path('pushnotification.php') : 'pushnotification.php'; $this->publishes([ __DIR__.'/../Config/config.php' => $config_path, __DIR__.'/../Config/iosCertificates' => config_path('iosCertificates/') ...
[ "public", "function", "boot", "(", ")", "{", "$", "config_path", "=", "function_exists", "(", "'config_path'", ")", "?", "config_path", "(", "'pushnotification.php'", ")", ":", "'pushnotification.php'", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ...
Bootstrap the application services. @return void
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Providers/PushNotificationServiceProvider.php#L15-L23
Edujugon/PushNotification
src/PushNotification.php
PushNotification.setService
public function setService($serviceName) { if (!array_key_exists($serviceName, $this->servicesList)) { $serviceName = $this->defaultServiceName; } $this->service = new $this->servicesList[$serviceName]; return $this; }
php
public function setService($serviceName) { if (!array_key_exists($serviceName, $this->servicesList)) { $serviceName = $this->defaultServiceName; } $this->service = new $this->servicesList[$serviceName]; return $this; }
[ "public", "function", "setService", "(", "$", "serviceName", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "serviceName", ",", "$", "this", "->", "servicesList", ")", ")", "{", "$", "serviceName", "=", "$", "this", "->", "defaultServiceName", ";"...
Set the Push Service to be used. @param $serviceName @return $this
[ "Set", "the", "Push", "Service", "to", "be", "used", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/PushNotification.php#L65-L74
Edujugon/PushNotification
src/Channels/PushChannel.php
PushChannel.send
public function send($notifiable, Notification $notification) { if (! $to = $notifiable->routeNotificationFor($this->notificationFor())) { return; } $message = $this->buildMessage($notifiable, $notification); $data = $this->buildData($message); $this->push($thi...
php
public function send($notifiable, Notification $notification) { if (! $to = $notifiable->routeNotificationFor($this->notificationFor())) { return; } $message = $this->buildMessage($notifiable, $notification); $data = $this->buildData($message); $this->push($thi...
[ "public", "function", "send", "(", "$", "notifiable", ",", "Notification", "$", "notification", ")", "{", "if", "(", "!", "$", "to", "=", "$", "notifiable", "->", "routeNotificationFor", "(", "$", "this", "->", "notificationFor", "(", ")", ")", ")", "{",...
Send the given notification. @param mixed $notifiable @param \Illuminate\Notifications\Notification $notification @return void
[ "Send", "the", "given", "notification", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Channels/PushChannel.php#L33-L44
Edujugon/PushNotification
src/Channels/PushChannel.php
PushChannel.push
protected function push($service, $to, $data, PushMessage $message) { $this->push->setMessage($data) ->setService($service) ->setDevicesToken($to); if (! empty($message->config)) { $this->push->setConfig($message->config); if (! empty($message->confi...
php
protected function push($service, $to, $data, PushMessage $message) { $this->push->setMessage($data) ->setService($service) ->setDevicesToken($to); if (! empty($message->config)) { $this->push->setConfig($message->config); if (! empty($message->confi...
[ "protected", "function", "push", "(", "$", "service", ",", "$", "to", ",", "$", "data", ",", "PushMessage", "$", "message", ")", "{", "$", "this", "->", "push", "->", "setMessage", "(", "$", "data", ")", "->", "setService", "(", "$", "service", ")", ...
Send the push notification. @param string $service @param mixed $to @param array $data @param \Edujugon\PushNotification\Messages\PushMessage $message @return mixed
[ "Send", "the", "push", "notification", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Channels/PushChannel.php#L55-L75
Edujugon/PushNotification
src/Channels/PushChannel.php
PushChannel.buildMessage
protected function buildMessage($notifiable, Notification $notification) { $message = call_user_func_array([$notification, $this->getToMethod()], [$notifiable]); if (is_string($message)) { $message = new PushMessage($message); } return $message; }
php
protected function buildMessage($notifiable, Notification $notification) { $message = call_user_func_array([$notification, $this->getToMethod()], [$notifiable]); if (is_string($message)) { $message = new PushMessage($message); } return $message; }
[ "protected", "function", "buildMessage", "(", "$", "notifiable", ",", "Notification", "$", "notification", ")", "{", "$", "message", "=", "call_user_func_array", "(", "[", "$", "notification", ",", "$", "this", "->", "getToMethod", "(", ")", "]", ",", "[", ...
Format the message. @param mixed $notifiable @param \Illuminate\Notifications\Notification $notification @return \Edujugon\PushNotification\Messages\PushMessage
[ "Format", "the", "message", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Channels/PushChannel.php#L84-L93
Edujugon/PushNotification
src/Channels/PushChannel.php
PushChannel.broadcast
protected function broadcast() { if (function_exists('broadcast')) { broadcast(new NotificationPushed($this->push)); } elseif (function_exists('event')) { event(new NotificationPushed($this->push)); } }
php
protected function broadcast() { if (function_exists('broadcast')) { broadcast(new NotificationPushed($this->push)); } elseif (function_exists('event')) { event(new NotificationPushed($this->push)); } }
[ "protected", "function", "broadcast", "(", ")", "{", "if", "(", "function_exists", "(", "'broadcast'", ")", ")", "{", "broadcast", "(", "new", "NotificationPushed", "(", "$", "this", "->", "push", ")", ")", ";", "}", "elseif", "(", "function_exists", "(", ...
BroadCast NotificationPushed event
[ "BroadCast", "NotificationPushed", "event" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Channels/PushChannel.php#L126-L133
Edujugon/PushNotification
src/Apn.php
Apn.setProperGateway
private function setProperGateway() { if (isset($this->config['dry_run'])) { if ($this->config['dry_run']) { $this->setUrl($this->sandboxUrl); $this->feedbackUrl = $this->feedbackSandboxUrl; } else { $this->setUrl($this->productionUrl)...
php
private function setProperGateway() { if (isset($this->config['dry_run'])) { if ($this->config['dry_run']) { $this->setUrl($this->sandboxUrl); $this->feedbackUrl = $this->feedbackSandboxUrl; } else { $this->setUrl($this->productionUrl)...
[ "private", "function", "setProperGateway", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'dry_run'", "]", ")", ")", "{", "if", "(", "$", "this", "->", "config", "[", "'dry_run'", "]", ")", "{", "$", "this", "->", "setUr...
Set the correct Gateway url and the Feedback url based on dry_run param. @return void
[ "Set", "the", "correct", "Gateway", "url", "and", "the", "Feedback", "url", "based", "on", "dry_run", "param", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L86-L98
Edujugon/PushNotification
src/Apn.php
Apn.setRetryAttemptsIfConfigured
private function setRetryAttemptsIfConfigured() { if (isset($this->config['connection_attempts']) && is_numeric($this->config['connection_attempts'])) { $this->maxAttempts = $this->config['connection_attempts']; } }
php
private function setRetryAttemptsIfConfigured() { if (isset($this->config['connection_attempts']) && is_numeric($this->config['connection_attempts'])) { $this->maxAttempts = $this->config['connection_attempts']; } }
[ "private", "function", "setRetryAttemptsIfConfigured", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'connection_attempts'", "]", ")", "&&", "is_numeric", "(", "$", "this", "->", "config", "[", "'connection_attempts'", "]", ")", ...
Configure re-try attempts. @return void
[ "Configure", "re", "-", "try", "attempts", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L105-L111
Edujugon/PushNotification
src/Apn.php
Apn.canRetry
private function canRetry() { if ($this->isUnlimitedAttempts()) { return true; } $this->attempts++; return $this->attempts < $this->maxAttempts; }
php
private function canRetry() { if ($this->isUnlimitedAttempts()) { return true; } $this->attempts++; return $this->attempts < $this->maxAttempts; }
[ "private", "function", "canRetry", "(", ")", "{", "if", "(", "$", "this", "->", "isUnlimitedAttempts", "(", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "attempts", "++", ";", "return", "$", "this", "->", "attempts", "<", "$", "this"...
Check if can retry a connection @return bool
[ "Check", "if", "can", "retry", "a", "connection" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L128-L137
Edujugon/PushNotification
src/Apn.php
Apn.getUnregisteredDeviceTokens
public function getUnregisteredDeviceTokens(array $devices_token) { $tokens = []; if (!empty($this->feedback->tokenFailList)) { $tokens = $this->feedback->tokenFailList; } if (!empty($this->feedback->apnsFeedback)) { $tokens = array_merge($tokens, array_pluck...
php
public function getUnregisteredDeviceTokens(array $devices_token) { $tokens = []; if (!empty($this->feedback->tokenFailList)) { $tokens = $this->feedback->tokenFailList; } if (!empty($this->feedback->apnsFeedback)) { $tokens = array_merge($tokens, array_pluck...
[ "public", "function", "getUnregisteredDeviceTokens", "(", "array", "$", "devices_token", ")", "{", "$", "tokens", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "feedback", "->", "tokenFailList", ")", ")", "{", "$", "tokens", "=", ...
Provide the unregistered tokens of the notification sent. @param array $devices_token @return array
[ "Provide", "the", "unregistered", "tokens", "of", "the", "notification", "sent", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L157-L169
Edujugon/PushNotification
src/Apn.php
Apn.existCertificate
private function existCertificate() { if (isset($this->config['certificate'])) { $certificate = $this->config['certificate']; if (!file_exists($certificate)) { $this->messageNoExistCertificate(); return false; } return true; ...
php
private function existCertificate() { if (isset($this->config['certificate'])) { $certificate = $this->config['certificate']; if (!file_exists($certificate)) { $this->messageNoExistCertificate(); return false; } return true; ...
[ "private", "function", "existCertificate", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'certificate'", "]", ")", ")", "{", "$", "certificate", "=", "$", "this", "->", "config", "[", "'certificate'", "]", ";", "if", "(", ...
Check if the certificate file exist. @return bool
[ "Check", "if", "the", "certificate", "file", "exist", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L190-L204
Edujugon/PushNotification
src/Apn.php
Apn.composeStreamSocket
private function composeStreamSocket() { $ctx = stream_context_create(); //Already checked if certificate exists. $certificate = $this->config['certificate']; stream_context_set_option($ctx, 'ssl', 'local_cert', $certificate); if (isset($this->config['passPhrase'])) { ...
php
private function composeStreamSocket() { $ctx = stream_context_create(); //Already checked if certificate exists. $certificate = $this->config['certificate']; stream_context_set_option($ctx, 'ssl', 'local_cert', $certificate); if (isset($this->config['passPhrase'])) { ...
[ "private", "function", "composeStreamSocket", "(", ")", "{", "$", "ctx", "=", "stream_context_create", "(", ")", ";", "//Already checked if certificate exists.", "$", "certificate", "=", "$", "this", "->", "config", "[", "'certificate'", "]", ";", "stream_context_se...
Compose the stream socket @return resource
[ "Compose", "the", "stream", "socket" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L211-L234
Edujugon/PushNotification
src/Apn.php
Apn.openConnectionAPNS
private function openConnectionAPNS($ctx) { $fp = false; // Open a connection to the APNS server try { $fp = stream_socket_client( $this->url, $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_P...
php
private function openConnectionAPNS($ctx) { $fp = false; // Open a connection to the APNS server try { $fp = stream_socket_client( $this->url, $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_P...
[ "private", "function", "openConnectionAPNS", "(", "$", "ctx", ")", "{", "$", "fp", "=", "false", ";", "// Open a connection to the APNS server", "try", "{", "$", "fp", "=", "stream_socket_client", "(", "$", "this", "->", "url", ",", "$", "err", ",", "$", "...
Create the connection to APNS server If some error, the error is stored in class feedback property. IF OKAY, return connection @return bool|resource
[ "Create", "the", "connection", "to", "APNS", "server", "If", "some", "error", "the", "error", "is", "stored", "in", "class", "feedback", "property", ".", "IF", "OKAY", "return", "connection" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L243-L280
Edujugon/PushNotification
src/Apn.php
Apn.send
public function send(array $deviceTokens, array $message) { /** * If there isn't certificate returns the feedback. * Feedback has been loaded in existCertificate method if no certificate found */ if (!$this->existCertificate()) { return $this->feedback; ...
php
public function send(array $deviceTokens, array $message) { /** * If there isn't certificate returns the feedback. * Feedback has been loaded in existCertificate method if no certificate found */ if (!$this->existCertificate()) { return $this->feedback; ...
[ "public", "function", "send", "(", "array", "$", "deviceTokens", ",", "array", "$", "message", ")", "{", "/**\n * If there isn't certificate returns the feedback.\n * Feedback has been loaded in existCertificate method if no certificate found\n */", "if", "(", ...
Send Push Notification @param array $deviceTokens @param array $message @return \stdClass APN Response
[ "Send", "Push", "Notification" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L288-L362
Edujugon/PushNotification
src/Apn.php
Apn.apnsFeedback
public function apnsFeedback() { $feedback_tokens = array(); if (!$this->existCertificate()) { return $feedback_tokens; } //connect to the APNS feedback servers $ctx = $this->composeStreamSocket(); // Open a connection to the APNS server try { ...
php
public function apnsFeedback() { $feedback_tokens = array(); if (!$this->existCertificate()) { return $feedback_tokens; } //connect to the APNS feedback servers $ctx = $this->composeStreamSocket(); // Open a connection to the APNS server try { ...
[ "public", "function", "apnsFeedback", "(", ")", "{", "$", "feedback_tokens", "=", "array", "(", ")", ";", "if", "(", "!", "$", "this", "->", "existCertificate", "(", ")", ")", "{", "return", "$", "feedback_tokens", ";", "}", "//connect to the APNS feedback s...
Get the unregistered device tokens from the apns feedback. Connect to apn server in order to collect the tokens of the apps which were removed from the device. @return array
[ "Get", "the", "unregistered", "device", "tokens", "from", "the", "apns", "feedback", ".", "Connect", "to", "apn", "server", "in", "order", "to", "collect", "the", "tokens", "of", "the", "apps", "which", "were", "removed", "from", "the", "device", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L370-L411
Edujugon/PushNotification
src/Apn.php
Apn.updateCustomFeedbackValues
private function updateCustomFeedbackValues($apnsFeedback, $feedback, $deviceTokens) { //Add failures amount based on apple feedback to our custom feedback $feedback['failure'] += count($apnsFeedback['apnsFeedback']); //apns tokens $apnsTokens = array_pluck($apnsFeedback['apnsFeedb...
php
private function updateCustomFeedbackValues($apnsFeedback, $feedback, $deviceTokens) { //Add failures amount based on apple feedback to our custom feedback $feedback['failure'] += count($apnsFeedback['apnsFeedback']); //apns tokens $apnsTokens = array_pluck($apnsFeedback['apnsFeedb...
[ "private", "function", "updateCustomFeedbackValues", "(", "$", "apnsFeedback", ",", "$", "feedback", ",", "$", "deviceTokens", ")", "{", "//Add failures amount based on apple feedback to our custom feedback", "$", "feedback", "[", "'failure'", "]", "+=", "count", "(", "...
Update the success and failure values based on apple feedback @param $apnsFeedback @param $feedback @param $deviceTokens @return array $feedback
[ "Update", "the", "success", "and", "failure", "values", "based", "on", "apple", "feedback" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Apn.php#L422-L440
Edujugon/PushNotification
src/Channels/ApnChannel.php
ApnChannel.buildData
protected function buildData(PushMessage $message) { $data = [ 'aps' => [ 'alert' => [ 'title' => $message->title, 'body' => $message->body, ], 'category' => $message->category, 'sound' => $me...
php
protected function buildData(PushMessage $message) { $data = [ 'aps' => [ 'alert' => [ 'title' => $message->title, 'body' => $message->body, ], 'category' => $message->category, 'sound' => $me...
[ "protected", "function", "buildData", "(", "PushMessage", "$", "message", ")", "{", "$", "data", "=", "[", "'aps'", "=>", "[", "'alert'", "=>", "[", "'title'", "=>", "$", "message", "->", "title", ",", "'body'", "=>", "$", "message", "->", "body", ",",...
{@inheritdoc}
[ "{" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Channels/ApnChannel.php#L20-L42
Edujugon/PushNotification
src/Channels/GcmChannel.php
GcmChannel.buildData
protected function buildData(PushMessage $message) { $data = []; if ($message->title != null || $message->body != null || $message->click_action != null) { $data = [ 'notification' => [ 'title' => $message->title, 'body' => $message...
php
protected function buildData(PushMessage $message) { $data = []; if ($message->title != null || $message->body != null || $message->click_action != null) { $data = [ 'notification' => [ 'title' => $message->title, 'body' => $message...
[ "protected", "function", "buildData", "(", "PushMessage", "$", "message", ")", "{", "$", "data", "=", "[", "]", ";", "if", "(", "$", "message", "->", "title", "!=", "null", "||", "$", "message", "->", "body", "!=", "null", "||", "$", "message", "->",...
{@inheritdoc}
[ "{" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Channels/GcmChannel.php#L20-L44
Edujugon/PushNotification
src/Gcm.php
Gcm.getUnregisteredDeviceTokens
public function getUnregisteredDeviceTokens(array $devices_token) { /** * If there is any failure sending the notification */ if ($this->feedback && isset($this->feedback->failure)) { $unRegisteredTokens = $devices_token; /** * Walk the array l...
php
public function getUnregisteredDeviceTokens(array $devices_token) { /** * If there is any failure sending the notification */ if ($this->feedback && isset($this->feedback->failure)) { $unRegisteredTokens = $devices_token; /** * Walk the array l...
[ "public", "function", "getUnregisteredDeviceTokens", "(", "array", "$", "devices_token", ")", "{", "/**\n * If there is any failure sending the notification\n */", "if", "(", "$", "this", "->", "feedback", "&&", "isset", "(", "$", "this", "->", "feedback",...
Provide the unregistered tokens of the sent notification. @param array $devices_token @return array $tokenUnRegistered
[ "Provide", "the", "unregistered", "tokens", "of", "the", "sent", "notification", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Gcm.php#L43-L65
Edujugon/PushNotification
src/Gcm.php
Gcm.addRequestFields
protected function addRequestFields($deviceTokens, $message) { $params = $this->cleanConfigParams(); $message = $this->buildMessage($message); return array_merge($params, $message, ['registration_ids' => $deviceTokens]); }
php
protected function addRequestFields($deviceTokens, $message) { $params = $this->cleanConfigParams(); $message = $this->buildMessage($message); return array_merge($params, $message, ['registration_ids' => $deviceTokens]); }
[ "protected", "function", "addRequestFields", "(", "$", "deviceTokens", ",", "$", "message", ")", "{", "$", "params", "=", "$", "this", "->", "cleanConfigParams", "(", ")", ";", "$", "message", "=", "$", "this", "->", "buildMessage", "(", "$", "message", ...
Set the needed fields for the push notification @param $deviceTokens @param $message @return array
[ "Set", "the", "needed", "fields", "for", "the", "push", "notification" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Gcm.php#L74-L82
Edujugon/PushNotification
src/Gcm.php
Gcm.cleanConfigParams
private function cleanConfigParams() { /** * Add the params you want to be removed from the push notification */ $paramsToBeRemoved = ['apiKey']; return array_filter($this->config, function ($key) use ($paramsToBeRemoved) { return !in_array($key, $paramsToBeRem...
php
private function cleanConfigParams() { /** * Add the params you want to be removed from the push notification */ $paramsToBeRemoved = ['apiKey']; return array_filter($this->config, function ($key) use ($paramsToBeRemoved) { return !in_array($key, $paramsToBeRem...
[ "private", "function", "cleanConfigParams", "(", ")", "{", "/**\n * Add the params you want to be removed from the push notification\n */", "$", "paramsToBeRemoved", "=", "[", "'apiKey'", "]", ";", "return", "array_filter", "(", "$", "this", "->", "config", ...
Clean the config params from unnecessary params no to make the notification too heavy. @return array
[ "Clean", "the", "config", "params", "from", "unnecessary", "params", "no", "to", "make", "the", "notification", "too", "heavy", "." ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Gcm.php#L103-L113
Edujugon/PushNotification
src/Gcm.php
Gcm.send
public function send(array $deviceTokens, array $message) { $fields = $this->addRequestFields($deviceTokens, $message); $headers = $this->addRequestHeaders(); try { $result = $this->client->post( $this->url, [ 'headers' => $he...
php
public function send(array $deviceTokens, array $message) { $fields = $this->addRequestFields($deviceTokens, $message); $headers = $this->addRequestHeaders(); try { $result = $this->client->post( $this->url, [ 'headers' => $he...
[ "public", "function", "send", "(", "array", "$", "deviceTokens", ",", "array", "$", "message", ")", "{", "$", "fields", "=", "$", "this", "->", "addRequestFields", "(", "$", "deviceTokens", ",", "$", "message", ")", ";", "$", "headers", "=", "$", "this...
Send Push Notification @param array $deviceTokens @param array $message @return \stdClass GCM Response
[ "Send", "Push", "Notification" ]
train
https://github.com/Edujugon/PushNotification/blob/7fd555c0149d669de7a34c159e8371187480e273/src/Gcm.php#L136-L164
dvdoug/BoxPacker
src/PackedItemList.php
PackedItemList.compare
private function compare(PackedItem $itemA, PackedItem $itemB): int { $itemAVolume = $itemA->getItem()->getWidth() * $itemA->getItem()->getLength() * $itemA->getItem()->getDepth(); $itemBVolume = $itemB->getItem()->getWidth() * $itemB->getItem()->getLength() * $itemB->getItem()->getDepth(); ...
php
private function compare(PackedItem $itemA, PackedItem $itemB): int { $itemAVolume = $itemA->getItem()->getWidth() * $itemA->getItem()->getLength() * $itemA->getItem()->getDepth(); $itemBVolume = $itemB->getItem()->getWidth() * $itemB->getItem()->getLength() * $itemB->getItem()->getDepth(); ...
[ "private", "function", "compare", "(", "PackedItem", "$", "itemA", ",", "PackedItem", "$", "itemB", ")", ":", "int", "{", "$", "itemAVolume", "=", "$", "itemA", "->", "getItem", "(", ")", "->", "getWidth", "(", ")", "*", "$", "itemA", "->", "getItem", ...
@param PackedItem $itemA @param PackedItem $itemB @return int
[ "@param", "PackedItem", "$itemA", "@param", "PackedItem", "$itemB" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedItemList.php#L91-L97
dvdoug/BoxPacker
src/ItemList.php
ItemList.remove
public function remove(Item $item): void { foreach ($this->list as $key => $itemToCheck) { if ($itemToCheck === $item) { unset($this->list[$key]); break; } } }
php
public function remove(Item $item): void { foreach ($this->list as $key => $itemToCheck) { if ($itemToCheck === $item) { unset($this->list[$key]); break; } } }
[ "public", "function", "remove", "(", "Item", "$", "item", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "list", "as", "$", "key", "=>", "$", "itemToCheck", ")", "{", "if", "(", "$", "itemToCheck", "===", "$", "item", ")", "{", "unset", ...
Remove item from list. @param Item $item
[ "Remove", "item", "from", "list", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/ItemList.php#L70-L78
dvdoug/BoxPacker
src/ItemList.php
ItemList.extract
public function extract(): Item { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } return array_pop($this->list); }
php
public function extract(): Item { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } return array_pop($this->list); }
[ "public", "function", "extract", "(", ")", ":", "Item", "{", "if", "(", "!", "$", "this", "->", "isSorted", ")", "{", "usort", "(", "$", "this", "->", "list", ",", "[", "$", "this", ",", "'compare'", "]", ")", ";", "$", "this", "->", "isSorted", ...
@internal @return Item
[ "@internal" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/ItemList.php#L85-L93
dvdoug/BoxPacker
src/ItemList.php
ItemList.top
public function top(): Item { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } $temp = $this->list; return end($temp); }
php
public function top(): Item { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } $temp = $this->list; return end($temp); }
[ "public", "function", "top", "(", ")", ":", "Item", "{", "if", "(", "!", "$", "this", "->", "isSorted", ")", "{", "usort", "(", "$", "this", "->", "list", ",", "[", "$", "this", ",", "'compare'", "]", ")", ";", "$", "this", "->", "isSorted", "=...
@internal @return Item
[ "@internal" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/ItemList.php#L100-L109
dvdoug/BoxPacker
src/ItemList.php
ItemList.topN
public function topN(int $n): self { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } $topNList = new self(); $topNList->insertFromArray(array_slice($this->list, -$n, $n)); return $topNList; }
php
public function topN(int $n): self { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } $topNList = new self(); $topNList->insertFromArray(array_slice($this->list, -$n, $n)); return $topNList; }
[ "public", "function", "topN", "(", "int", "$", "n", ")", ":", "self", "{", "if", "(", "!", "$", "this", "->", "isSorted", ")", "{", "usort", "(", "$", "this", "->", "list", ",", "[", "$", "this", ",", "'compare'", "]", ")", ";", "$", "this", ...
@internal @param int $n @return ItemList
[ "@internal" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/ItemList.php#L117-L128
dvdoug/BoxPacker
src/ItemList.php
ItemList.compare
private function compare(Item $itemA, Item $itemB): int { $itemAVolume = $itemA->getWidth() * $itemA->getLength() * $itemA->getDepth(); $itemBVolume = $itemB->getWidth() * $itemB->getLength() * $itemB->getDepth(); $volumeDecider = $itemAVolume <=> $itemBVolume; $weightDecider = $item...
php
private function compare(Item $itemA, Item $itemB): int { $itemAVolume = $itemA->getWidth() * $itemA->getLength() * $itemA->getDepth(); $itemBVolume = $itemB->getWidth() * $itemB->getLength() * $itemB->getDepth(); $volumeDecider = $itemAVolume <=> $itemBVolume; $weightDecider = $item...
[ "private", "function", "compare", "(", "Item", "$", "itemA", ",", "Item", "$", "itemB", ")", ":", "int", "{", "$", "itemAVolume", "=", "$", "itemA", "->", "getWidth", "(", ")", "*", "$", "itemA", "->", "getLength", "(", ")", "*", "$", "itemA", "->"...
@param Item $itemA @param Item $itemB @return int
[ "@param", "Item", "$itemA", "@param", "Item", "$itemB" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/ItemList.php#L159-L173
dvdoug/BoxPacker
src/BoxList.php
BoxList.compare
public function compare($boxA, $boxB): int { $boxAVolume = $boxA->getInnerWidth() * $boxA->getInnerLength() * $boxA->getInnerDepth(); $boxBVolume = $boxB->getInnerWidth() * $boxB->getInnerLength() * $boxB->getInnerDepth(); return $boxAVolume <=> $boxBVolume; }
php
public function compare($boxA, $boxB): int { $boxAVolume = $boxA->getInnerWidth() * $boxA->getInnerLength() * $boxA->getInnerDepth(); $boxBVolume = $boxB->getInnerWidth() * $boxB->getInnerLength() * $boxB->getInnerDepth(); return $boxAVolume <=> $boxBVolume; }
[ "public", "function", "compare", "(", "$", "boxA", ",", "$", "boxB", ")", ":", "int", "{", "$", "boxAVolume", "=", "$", "boxA", "->", "getInnerWidth", "(", ")", "*", "$", "boxA", "->", "getInnerLength", "(", ")", "*", "$", "boxA", "->", "getInnerDept...
@param Box $boxA @param Box $boxB @return int
[ "@param", "Box", "$boxA", "@param", "Box", "$boxB" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/BoxList.php#L64-L70
dvdoug/BoxPacker
src/PackedLayer.php
PackedLayer.getFootprint
public function getFootprint(): int { $layerWidth = 0; $layerLength = 0; foreach ($this->items as $item) { $layerWidth = max($layerWidth, $item->getX() + $item->getWidth()); $layerLength = max($layerLength, $item->getY() + $item->getLength()); } retu...
php
public function getFootprint(): int { $layerWidth = 0; $layerLength = 0; foreach ($this->items as $item) { $layerWidth = max($layerWidth, $item->getX() + $item->getWidth()); $layerLength = max($layerLength, $item->getY() + $item->getLength()); } retu...
[ "public", "function", "getFootprint", "(", ")", ":", "int", "{", "$", "layerWidth", "=", "0", ";", "$", "layerLength", "=", "0", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "layerWidth", "=", "max", "(", "$", ...
Calculate footprint area of this layer. @return int mm^2
[ "Calculate", "footprint", "area", "of", "this", "layer", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedLayer.php#L54-L65
dvdoug/BoxPacker
src/PackedLayer.php
PackedLayer.getStartDepth
public function getStartDepth(): int { $startDepth = PHP_INT_MAX; foreach ($this->items as $item) { $startDepth = min($startDepth, $item->getZ()); } return $startDepth; }
php
public function getStartDepth(): int { $startDepth = PHP_INT_MAX; foreach ($this->items as $item) { $startDepth = min($startDepth, $item->getZ()); } return $startDepth; }
[ "public", "function", "getStartDepth", "(", ")", ":", "int", "{", "$", "startDepth", "=", "PHP_INT_MAX", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "startDepth", "=", "min", "(", "$", "startDepth", ",", "$", "i...
Calculate start depth of this layer. @return int mm
[ "Calculate", "start", "depth", "of", "this", "layer", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedLayer.php#L72-L81
dvdoug/BoxPacker
src/PackedLayer.php
PackedLayer.getDepth
public function getDepth(): int { $layerDepth = 0; foreach ($this->items as $item) { $layerDepth = max($layerDepth, $item->getZ() + $item->getDepth()); } return $layerDepth - $this->getStartDepth(); }
php
public function getDepth(): int { $layerDepth = 0; foreach ($this->items as $item) { $layerDepth = max($layerDepth, $item->getZ() + $item->getDepth()); } return $layerDepth - $this->getStartDepth(); }
[ "public", "function", "getDepth", "(", ")", ":", "int", "{", "$", "layerDepth", "=", "0", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "layerDepth", "=", "max", "(", "$", "layerDepth", ",", "$", "item", "->", ...
Calculate depth of this layer. @return int mm
[ "Calculate", "depth", "of", "this", "layer", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedLayer.php#L88-L97
dvdoug/BoxPacker
src/WorkingVolume.php
WorkingVolume.jsonSerialize
public function jsonSerialize(): array { return [ 'reference' => $this->getReference(), 'width' => $this->width, 'length' => $this->length, 'depth' => $this->depth, 'maxWeight' => $this->maxWeight, ]; }
php
public function jsonSerialize(): array { return [ 'reference' => $this->getReference(), 'width' => $this->width, 'length' => $this->length, 'depth' => $this->depth, 'maxWeight' => $this->maxWeight, ]; }
[ "public", "function", "jsonSerialize", "(", ")", ":", "array", "{", "return", "[", "'reference'", "=>", "$", "this", "->", "getReference", "(", ")", ",", "'width'", "=>", "$", "this", "->", "width", ",", "'length'", "=>", "$", "this", "->", "length", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/WorkingVolume.php#L134-L143
dvdoug/BoxPacker
src/InfalliblePacker.php
InfalliblePacker.pack
public function pack(): PackedBoxList { $itemList = clone $this->items; while (true) { try { return parent::pack(); } catch (ItemTooLargeException $e) { $this->unpackedItems->insert($e->getItem()); $itemList->remove($e->getItem...
php
public function pack(): PackedBoxList { $itemList = clone $this->items; while (true) { try { return parent::pack(); } catch (ItemTooLargeException $e) { $this->unpackedItems->insert($e->getItem()); $itemList->remove($e->getItem...
[ "public", "function", "pack", "(", ")", ":", "PackedBoxList", "{", "$", "itemList", "=", "clone", "$", "this", "->", "items", ";", "while", "(", "true", ")", "{", "try", "{", "return", "parent", "::", "pack", "(", ")", ";", "}", "catch", "(", "Item...
{@inheritdoc}
[ "{" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/InfalliblePacker.php#L45-L58
dvdoug/BoxPacker
src/LayerStabiliser.php
LayerStabiliser.stabilise
public function stabilise(array $packedLayers): array { // first re-order according to footprint $stabilisedLayers = []; usort($packedLayers, [$this, 'compare']); // then for each item in the layer, re-calculate each item's z position $currentZ = 0; foreach ($packedL...
php
public function stabilise(array $packedLayers): array { // first re-order according to footprint $stabilisedLayers = []; usort($packedLayers, [$this, 'compare']); // then for each item in the layer, re-calculate each item's z position $currentZ = 0; foreach ($packedL...
[ "public", "function", "stabilise", "(", "array", "$", "packedLayers", ")", ":", "array", "{", "// first re-order according to footprint", "$", "stabilisedLayers", "=", "[", "]", ";", "usort", "(", "$", "packedLayers", ",", "[", "$", "this", ",", "'compare'", "...
@param PackedLayer[] $packedLayers @return PackedLayer[]
[ "@param", "PackedLayer", "[]", "$packedLayers" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/LayerStabiliser.php#L39-L61
dvdoug/BoxPacker
src/LayerStabiliser.php
LayerStabiliser.compare
private function compare(PackedLayer $layerA, PackedLayer $layerB): int { return ($layerB->getFootprint() <=> $layerA->getFootprint()) ?: ($layerB->getDepth() <=> $layerA->getDepth()); }
php
private function compare(PackedLayer $layerA, PackedLayer $layerB): int { return ($layerB->getFootprint() <=> $layerA->getFootprint()) ?: ($layerB->getDepth() <=> $layerA->getDepth()); }
[ "private", "function", "compare", "(", "PackedLayer", "$", "layerA", ",", "PackedLayer", "$", "layerB", ")", ":", "int", "{", "return", "(", "$", "layerB", "->", "getFootprint", "(", ")", "<=>", "$", "layerA", "->", "getFootprint", "(", ")", ")", "?", ...
@param PackedLayer $layerA @param PackedLayer $layerB @return int
[ "@param", "PackedLayer", "$layerA", "@param", "PackedLayer", "$layerB" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/LayerStabiliser.php#L69-L72
dvdoug/BoxPacker
src/PackedBox.php
PackedBox.getItemWeight
public function getItemWeight(): int { if ($this->itemWeight !== null) { return $this->itemWeight; } $this->itemWeight = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $this->itemWeight += $item->getItem()->getWeight(); } ...
php
public function getItemWeight(): int { if ($this->itemWeight !== null) { return $this->itemWeight; } $this->itemWeight = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $this->itemWeight += $item->getItem()->getWeight(); } ...
[ "public", "function", "getItemWeight", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "itemWeight", "!==", "null", ")", "{", "return", "$", "this", "->", "itemWeight", ";", "}", "$", "this", "->", "itemWeight", "=", "0", ";", "/** @var Packed...
Get packed weight of the items only. @return int weight in grams
[ "Get", "packed", "weight", "of", "the", "items", "only", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBox.php#L77-L90
dvdoug/BoxPacker
src/PackedBox.php
PackedBox.getUsedWidth
public function getUsedWidth(): int { $maxWidth = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $maxWidth = max($maxWidth, $item->getX() + $item->getWidth()); } return $maxWidth; }
php
public function getUsedWidth(): int { $maxWidth = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $maxWidth = max($maxWidth, $item->getX() + $item->getWidth()); } return $maxWidth; }
[ "public", "function", "getUsedWidth", "(", ")", ":", "int", "{", "$", "maxWidth", "=", "0", ";", "/** @var PackedItem $item */", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "maxWidth", "=", "max", "(", "$", "maxWidth", ...
Used width inside box for packing items. @return int
[ "Used", "width", "inside", "box", "for", "packing", "items", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBox.php#L127-L137
dvdoug/BoxPacker
src/PackedBox.php
PackedBox.getUsedLength
public function getUsedLength(): int { $maxLength = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $maxLength = max($maxLength, $item->getY() + $item->getLength()); } return $maxLength; }
php
public function getUsedLength(): int { $maxLength = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $maxLength = max($maxLength, $item->getY() + $item->getLength()); } return $maxLength; }
[ "public", "function", "getUsedLength", "(", ")", ":", "int", "{", "$", "maxLength", "=", "0", ";", "/** @var PackedItem $item */", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "maxLength", "=", "max", "(", "$", "maxLength...
Used length inside box for packing items. @return int
[ "Used", "length", "inside", "box", "for", "packing", "items", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBox.php#L144-L154
dvdoug/BoxPacker
src/PackedBox.php
PackedBox.getUsedDepth
public function getUsedDepth(): int { $maxDepth = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $maxDepth = max($maxDepth, $item->getZ() + $item->getDepth()); } return $maxDepth; }
php
public function getUsedDepth(): int { $maxDepth = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $maxDepth = max($maxDepth, $item->getZ() + $item->getDepth()); } return $maxDepth; }
[ "public", "function", "getUsedDepth", "(", ")", ":", "int", "{", "$", "maxDepth", "=", "0", ";", "/** @var PackedItem $item */", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "maxDepth", "=", "max", "(", "$", "maxDepth", ...
Used depth inside box for packing items. @return int
[ "Used", "depth", "inside", "box", "for", "packing", "items", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBox.php#L161-L171
dvdoug/BoxPacker
src/PackedBox.php
PackedBox.getUsedVolume
public function getUsedVolume(): int { $volume = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $volume += $item->getVolume(); } return $volume; }
php
public function getUsedVolume(): int { $volume = 0; /** @var PackedItem $item */ foreach ($this->items as $item) { $volume += $item->getVolume(); } return $volume; }
[ "public", "function", "getUsedVolume", "(", ")", ":", "int", "{", "$", "volume", "=", "0", ";", "/** @var PackedItem $item */", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "volume", "+=", "$", "item", "->", "getVolume", ...
Get used volume of the packed box. @return int
[ "Get", "used", "volume", "of", "the", "packed", "box", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBox.php#L196-L206
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.pack
public function pack(): PackedBox { $this->logger->debug("[EVALUATING BOX] {$this->box->getReference()}", ['box' => $this->box]); while (count($this->items) > 0) { $layerStartDepth = $this->getCurrentPackedDepth(); $this->packLayer($layerStartDepth, $this->boxWidth, $this->b...
php
public function pack(): PackedBox { $this->logger->debug("[EVALUATING BOX] {$this->box->getReference()}", ['box' => $this->box]); while (count($this->items) > 0) { $layerStartDepth = $this->getCurrentPackedDepth(); $this->packLayer($layerStartDepth, $this->boxWidth, $this->b...
[ "public", "function", "pack", "(", ")", ":", "PackedBox", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"[EVALUATING BOX] {$this->box->getReference()}\"", ",", "[", "'box'", "=>", "$", "this", "->", "box", "]", ")", ";", "while", "(", "count", "(...
Pack as many items as possible into specific given box. @return PackedBox packed box
[ "Pack", "as", "many", "items", "as", "possible", "into", "specific", "given", "box", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L105-L123
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.packLayer
protected function packLayer(int $startDepth, int $widthLeft, int $lengthLeft, int $depthLeft): void { $this->layers[] = $layer = new PackedLayer(); $prevItem = null; $x = $y = $rowWidth = $rowLength = $layerDepth = 0; while (count($this->items) > 0) { $itemToPack = $thi...
php
protected function packLayer(int $startDepth, int $widthLeft, int $lengthLeft, int $depthLeft): void { $this->layers[] = $layer = new PackedLayer(); $prevItem = null; $x = $y = $rowWidth = $rowLength = $layerDepth = 0; while (count($this->items) > 0) { $itemToPack = $thi...
[ "protected", "function", "packLayer", "(", "int", "$", "startDepth", ",", "int", "$", "widthLeft", ",", "int", "$", "lengthLeft", ",", "int", "$", "depthLeft", ")", ":", "void", "{", "$", "this", "->", "layers", "[", "]", "=", "$", "layer", "=", "new...
Pack items into an individual vertical layer. @param int $startDepth @param int $widthLeft @param int $lengthLeft @param int $depthLeft
[ "Pack", "items", "into", "an", "individual", "vertical", "layer", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L133-L189
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.stabiliseLayers
public function stabiliseLayers(): void { $stabiliser = new LayerStabiliser(); $this->layers = $stabiliser->stabilise($this->layers); }
php
public function stabiliseLayers(): void { $stabiliser = new LayerStabiliser(); $this->layers = $stabiliser->stabilise($this->layers); }
[ "public", "function", "stabiliseLayers", "(", ")", ":", "void", "{", "$", "stabiliser", "=", "new", "LayerStabiliser", "(", ")", ";", "$", "this", "->", "layers", "=", "$", "stabiliser", "->", "stabilise", "(", "$", "this", "->", "layers", ")", ";", "}...
During packing, it is quite possible that layers have been created that aren't physically stable i.e. they overhang the ones below. This function reorders them so that the ones with the greatest surface area are placed at the bottom
[ "During", "packing", "it", "is", "quite", "possible", "that", "layers", "have", "been", "created", "that", "aren", "t", "physically", "stable", "i", ".", "e", ".", "they", "overhang", "the", "ones", "below", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L197-L201
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.getOrientationForItem
protected function getOrientationForItem( Item $itemToPack, ?PackedItem $prevItem, ItemList $nextItems, bool $isLastItem, int $maxWidth, int $maxLength, int $maxDepth, int $rowLength ): ?OrientatedItem { $this->logger->debug( "evalu...
php
protected function getOrientationForItem( Item $itemToPack, ?PackedItem $prevItem, ItemList $nextItems, bool $isLastItem, int $maxWidth, int $maxLength, int $maxDepth, int $rowLength ): ?OrientatedItem { $this->logger->debug( "evalu...
[ "protected", "function", "getOrientationForItem", "(", "Item", "$", "itemToPack", ",", "?", "PackedItem", "$", "prevItem", ",", "ItemList", "$", "nextItems", ",", "bool", "$", "isLastItem", ",", "int", "$", "maxWidth", ",", "int", "$", "maxLength", ",", "int...
@param Item $itemToPack @param PackedItem|null $prevItem @param ItemList $nextItems @param bool $isLastItem @param int $maxWidth @param int $maxLength @param int $maxDepth @param int $rowLength @return OrientatedItem|null
[ "@param", "Item", "$itemToPack", "@param", "PackedItem|null", "$prevItem", "@param", "ItemList", "$nextItems", "@param", "bool", "$isLastItem", "@param", "int", "$maxWidth", "@param", "int", "$maxLength", "@param", "int", "$maxDepth", "@param", "int", "$rowLength" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L215-L244
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.tryAndStackItemsIntoSpace
protected function tryAndStackItemsIntoSpace( PackedLayer $layer, ?PackedItem $prevItem, ItemList $nextItems, int $maxWidth, int $maxLength, int $maxDepth, int $x, int $y, int $z, int $rowLength ): void { while (count($this->ite...
php
protected function tryAndStackItemsIntoSpace( PackedLayer $layer, ?PackedItem $prevItem, ItemList $nextItems, int $maxWidth, int $maxLength, int $maxDepth, int $x, int $y, int $z, int $rowLength ): void { while (count($this->ite...
[ "protected", "function", "tryAndStackItemsIntoSpace", "(", "PackedLayer", "$", "layer", ",", "?", "PackedItem", "$", "prevItem", ",", "ItemList", "$", "nextItems", ",", "int", "$", "maxWidth", ",", "int", "$", "maxLength", ",", "int", "$", "maxDepth", ",", "...
Figure out if we can stack the next item vertically on top of this rather than side by side Used when we've packed a tall item, and have just put a shorter one next to it. @param PackedLayer $layer @param PackedItem|null $prevItem @param ItemList $nextItems @param int $maxWidth @param int ...
[ "Figure", "out", "if", "we", "can", "stack", "the", "next", "item", "vertically", "on", "top", "of", "this", "rather", "than", "side", "by", "side", "Used", "when", "we", "ve", "packed", "a", "tall", "item", "and", "have", "just", "put", "a", "shorter"...
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L260-L293
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.checkConstraints
protected function checkConstraints( Item $itemToPack ): bool { return $this->checkNonDimensionalConstraints($itemToPack) && $this->checkDimensionalConstraints($itemToPack); }
php
protected function checkConstraints( Item $itemToPack ): bool { return $this->checkNonDimensionalConstraints($itemToPack) && $this->checkDimensionalConstraints($itemToPack); }
[ "protected", "function", "checkConstraints", "(", "Item", "$", "itemToPack", ")", ":", "bool", "{", "return", "$", "this", "->", "checkNonDimensionalConstraints", "(", "$", "itemToPack", ")", "&&", "$", "this", "->", "checkDimensionalConstraints", "(", "$", "ite...
Check item generally fits into box. @param Item $itemToPack @return bool
[ "Check", "item", "generally", "fits", "into", "box", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L302-L307
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.checkNonDimensionalConstraints
protected function checkNonDimensionalConstraints(Item $itemToPack): bool { $weightOK = $itemToPack->getWeight() <= $this->remainingWeight; if ($itemToPack instanceof ConstrainedItem) { return $weightOK && $itemToPack->canBePackedInBox($this->getPackedItemList(), $this->box); } ...
php
protected function checkNonDimensionalConstraints(Item $itemToPack): bool { $weightOK = $itemToPack->getWeight() <= $this->remainingWeight; if ($itemToPack instanceof ConstrainedItem) { return $weightOK && $itemToPack->canBePackedInBox($this->getPackedItemList(), $this->box); } ...
[ "protected", "function", "checkNonDimensionalConstraints", "(", "Item", "$", "itemToPack", ")", ":", "bool", "{", "$", "weightOK", "=", "$", "itemToPack", "->", "getWeight", "(", ")", "<=", "$", "this", "->", "remainingWeight", ";", "if", "(", "$", "itemToPa...
As well as purely dimensional constraints, there are other constraints that need to be met e.g. weight limits or item-specific restrictions (e.g. max <x> batteries per box). @param Item $itemToPack @return bool
[ "As", "well", "as", "purely", "dimensional", "constraints", "there", "are", "other", "constraints", "that", "need", "to", "be", "met", "e", ".", "g", ".", "weight", "limits", "or", "item", "-", "specific", "restrictions", "(", "e", ".", "g", ".", "max", ...
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L317-L326
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.checkDimensionalConstraints
protected function checkDimensionalConstraints(Item $itemToPack): bool { $orientatedItemFactory = new OrientatedItemFactory($this->box); $orientatedItemFactory->setLogger($this->logger); return (bool) $orientatedItemFactory->getPossibleOrientationsInEmptyBox($itemToPack); }
php
protected function checkDimensionalConstraints(Item $itemToPack): bool { $orientatedItemFactory = new OrientatedItemFactory($this->box); $orientatedItemFactory->setLogger($this->logger); return (bool) $orientatedItemFactory->getPossibleOrientationsInEmptyBox($itemToPack); }
[ "protected", "function", "checkDimensionalConstraints", "(", "Item", "$", "itemToPack", ")", ":", "bool", "{", "$", "orientatedItemFactory", "=", "new", "OrientatedItemFactory", "(", "$", "this", "->", "box", ")", ";", "$", "orientatedItemFactory", "->", "setLogge...
Check the item physically fits in the box (at all). @param Item $itemToPack @return bool
[ "Check", "the", "item", "physically", "fits", "in", "the", "box", "(", "at", "all", ")", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L335-L341
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.rebuildItemList
protected function rebuildItemList(?Item $currentItem = null): void { if (count($this->items) === 0) { $this->items = $this->skippedItems; $this->skippedItems = new ItemList(); } if ($currentItem instanceof Item) { $this->items->insert($currentItem); ...
php
protected function rebuildItemList(?Item $currentItem = null): void { if (count($this->items) === 0) { $this->items = $this->skippedItems; $this->skippedItems = new ItemList(); } if ($currentItem instanceof Item) { $this->items->insert($currentItem); ...
[ "protected", "function", "rebuildItemList", "(", "?", "Item", "$", "currentItem", "=", "null", ")", ":", "void", "{", "if", "(", "count", "(", "$", "this", "->", "items", ")", "===", "0", ")", "{", "$", "this", "->", "items", "=", "$", "this", "->"...
Reintegrate skipped items into main list. @param Item|null $currentItem item from current iteration
[ "Reintegrate", "skipped", "items", "into", "main", "list", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L348-L358
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.rotateLayersNinetyDegrees
protected function rotateLayersNinetyDegrees(): void { foreach ($this->layers as $i => $originalLayer) { $newLayer = new PackedLayer(); foreach ($originalLayer->getItems() as $item) { $packedItem = new PackedItem($item->getItem(), $item->getY(), $item->getX(), $item->...
php
protected function rotateLayersNinetyDegrees(): void { foreach ($this->layers as $i => $originalLayer) { $newLayer = new PackedLayer(); foreach ($originalLayer->getItems() as $item) { $packedItem = new PackedItem($item->getItem(), $item->getY(), $item->getX(), $item->...
[ "protected", "function", "rotateLayersNinetyDegrees", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "layers", "as", "$", "i", "=>", "$", "originalLayer", ")", "{", "$", "newLayer", "=", "new", "PackedLayer", "(", ")", ";", "foreach", "("...
Swap back width/length of the packed items to match orientation of the box if needed.
[ "Swap", "back", "width", "/", "length", "of", "the", "packed", "items", "to", "match", "orientation", "of", "the", "box", "if", "needed", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L363-L373
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.getPackedItemList
protected function getPackedItemList(): PackedItemList { $packedItemList = new PackedItemList(); foreach ($this->layers as $layer) { foreach ($layer->getItems() as $packedItem) { $packedItemList->insert($packedItem); } } return $packedItemList...
php
protected function getPackedItemList(): PackedItemList { $packedItemList = new PackedItemList(); foreach ($this->layers as $layer) { foreach ($layer->getItems() as $packedItem) { $packedItemList->insert($packedItem); } } return $packedItemList...
[ "protected", "function", "getPackedItemList", "(", ")", ":", "PackedItemList", "{", "$", "packedItemList", "=", "new", "PackedItemList", "(", ")", ";", "foreach", "(", "$", "this", "->", "layers", "as", "$", "layer", ")", "{", "foreach", "(", "$", "layer",...
Generate a single list of items packed. @return PackedItemList
[ "Generate", "a", "single", "list", "of", "items", "packed", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L390-L400
dvdoug/BoxPacker
src/VolumePacker.php
VolumePacker.getCurrentPackedDepth
protected function getCurrentPackedDepth(): int { $depth = 0; foreach ($this->layers as $layer) { $depth += $layer->getDepth(); } return $depth; }
php
protected function getCurrentPackedDepth(): int { $depth = 0; foreach ($this->layers as $layer) { $depth += $layer->getDepth(); } return $depth; }
[ "protected", "function", "getCurrentPackedDepth", "(", ")", ":", "int", "{", "$", "depth", "=", "0", ";", "foreach", "(", "$", "this", "->", "layers", "as", "$", "layer", ")", "{", "$", "depth", "+=", "$", "layer", "->", "getDepth", "(", ")", ";", ...
Return the current packed depth. @return int
[ "Return", "the", "current", "packed", "depth", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/VolumePacker.php#L407-L415
dvdoug/BoxPacker
src/OrientatedItemFactory.php
OrientatedItemFactory.getBestOrientation
public function getBestOrientation( Item $item, ?OrientatedItem $prevItem, ItemList $nextItems, bool $isLastItem, int $widthLeft, int $lengthLeft, int $depthLeft, int $rowLength ): ?OrientatedItem { $possibleOrientations = $this->getPossibleOri...
php
public function getBestOrientation( Item $item, ?OrientatedItem $prevItem, ItemList $nextItems, bool $isLastItem, int $widthLeft, int $lengthLeft, int $depthLeft, int $rowLength ): ?OrientatedItem { $possibleOrientations = $this->getPossibleOri...
[ "public", "function", "getBestOrientation", "(", "Item", "$", "item", ",", "?", "OrientatedItem", "$", "prevItem", ",", "ItemList", "$", "nextItems", ",", "bool", "$", "isLastItem", ",", "int", "$", "widthLeft", ",", "int", "$", "lengthLeft", ",", "int", "...
Get the best orientation for an item. @param Item $item @param OrientatedItem|null $prevItem @param ItemList $nextItems @param bool $isLastItem @param int $widthLeft @param int $lengthLeft @param int $depthLeft @param int ...
[ "Get", "the", "best", "orientation", "for", "an", "item", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/OrientatedItemFactory.php#L57-L118
dvdoug/BoxPacker
src/OrientatedItemFactory.php
OrientatedItemFactory.getPossibleOrientations
public function getPossibleOrientations( Item $item, ?OrientatedItem $prevItem, int $widthLeft, int $lengthLeft, int $depthLeft ): array { $orientations = []; //Special case items that are the same as what we just packed - keep orientation if ($prevIt...
php
public function getPossibleOrientations( Item $item, ?OrientatedItem $prevItem, int $widthLeft, int $lengthLeft, int $depthLeft ): array { $orientations = []; //Special case items that are the same as what we just packed - keep orientation if ($prevIt...
[ "public", "function", "getPossibleOrientations", "(", "Item", "$", "item", ",", "?", "OrientatedItem", "$", "prevItem", ",", "int", "$", "widthLeft", ",", "int", "$", "lengthLeft", ",", "int", "$", "depthLeft", ")", ":", "array", "{", "$", "orientations", ...
Find all possible orientations for an item. @param Item $item @param OrientatedItem|null $prevItem @param int $widthLeft @param int $lengthLeft @param int $depthLeft @return OrientatedItem[]
[ "Find", "all", "possible", "orientations", "for", "an", "item", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/OrientatedItemFactory.php#L131-L163
dvdoug/BoxPacker
src/OrientatedItemFactory.php
OrientatedItemFactory.getUsableOrientations
protected function getUsableOrientations( Item $item, $possibleOrientations, bool $isLastItem ): array { $orientationsToUse = $stableOrientations = $unstableOrientations = []; // Divide possible orientations into stable (low centre of gravity) and unstable (high centre of gr...
php
protected function getUsableOrientations( Item $item, $possibleOrientations, bool $isLastItem ): array { $orientationsToUse = $stableOrientations = $unstableOrientations = []; // Divide possible orientations into stable (low centre of gravity) and unstable (high centre of gr...
[ "protected", "function", "getUsableOrientations", "(", "Item", "$", "item", ",", "$", "possibleOrientations", ",", "bool", "$", "isLastItem", ")", ":", "array", "{", "$", "orientationsToUse", "=", "$", "stableOrientations", "=", "$", "unstableOrientations", "=", ...
@param Item $item @param OrientatedItem[] $possibleOrientations @param bool $isLastItem @return OrientatedItem[]
[ "@param", "Item", "$item", "@param", "OrientatedItem", "[]", "$possibleOrientations", "@param", "bool", "$isLastItem" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/OrientatedItemFactory.php#L208-L240
dvdoug/BoxPacker
src/OrientatedItemFactory.php
OrientatedItemFactory.getStableOrientationsInEmptyBox
protected function getStableOrientationsInEmptyBox(Item $item): array { $orientationsInEmptyBox = $this->getPossibleOrientationsInEmptyBox($item); return array_filter( $orientationsInEmptyBox, function (OrientatedItem $orientation) { return $orientation->isSt...
php
protected function getStableOrientationsInEmptyBox(Item $item): array { $orientationsInEmptyBox = $this->getPossibleOrientationsInEmptyBox($item); return array_filter( $orientationsInEmptyBox, function (OrientatedItem $orientation) { return $orientation->isSt...
[ "protected", "function", "getStableOrientationsInEmptyBox", "(", "Item", "$", "item", ")", ":", "array", "{", "$", "orientationsInEmptyBox", "=", "$", "this", "->", "getPossibleOrientationsInEmptyBox", "(", "$", "item", ")", ";", "return", "array_filter", "(", "$"...
Return the orientations for this item if it were to be placed into the box with nothing else. @param Item $item @return array
[ "Return", "the", "orientations", "for", "this", "item", "if", "it", "were", "to", "be", "placed", "into", "the", "box", "with", "nothing", "else", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/OrientatedItemFactory.php#L248-L258
dvdoug/BoxPacker
src/OrientatedItemFactory.php
OrientatedItemFactory.isSameDimensions
protected function isSameDimensions(Item $itemA, Item $itemB): bool { $itemADimensions = [$itemA->getWidth(), $itemA->getLength(), $itemA->getDepth()]; $itemBDimensions = [$itemB->getWidth(), $itemB->getLength(), $itemB->getDepth()]; sort($itemADimensions); sort($itemBDimensions); ...
php
protected function isSameDimensions(Item $itemA, Item $itemB): bool { $itemADimensions = [$itemA->getWidth(), $itemA->getLength(), $itemA->getDepth()]; $itemBDimensions = [$itemB->getWidth(), $itemB->getLength(), $itemB->getDepth()]; sort($itemADimensions); sort($itemBDimensions); ...
[ "protected", "function", "isSameDimensions", "(", "Item", "$", "itemA", ",", "Item", "$", "itemB", ")", ":", "bool", "{", "$", "itemADimensions", "=", "[", "$", "itemA", "->", "getWidth", "(", ")", ",", "$", "itemA", "->", "getLength", "(", ")", ",", ...
Compare two items to see if they have same dimensions. @param Item $itemA @param Item $itemB @return bool
[ "Compare", "two", "items", "to", "see", "if", "they", "have", "same", "dimensions", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/OrientatedItemFactory.php#L268-L276
dvdoug/BoxPacker
src/OrientatedItemFactory.php
OrientatedItemFactory.calculateAdditionalItemsPackedWithThisOrientation
protected function calculateAdditionalItemsPackedWithThisOrientation( OrientatedItem $prevItem, ItemList $nextItems, int $originalWidthLeft, int $originalLengthLeft, int $depthLeft, int $currentRowLengthBeforePacking ): int { $packedCount = 0; $curren...
php
protected function calculateAdditionalItemsPackedWithThisOrientation( OrientatedItem $prevItem, ItemList $nextItems, int $originalWidthLeft, int $originalLengthLeft, int $depthLeft, int $currentRowLengthBeforePacking ): int { $packedCount = 0; $curren...
[ "protected", "function", "calculateAdditionalItemsPackedWithThisOrientation", "(", "OrientatedItem", "$", "prevItem", ",", "ItemList", "$", "nextItems", ",", "int", "$", "originalWidthLeft", ",", "int", "$", "originalLengthLeft", ",", "int", "$", "depthLeft", ",", "in...
Approximation of a forward-looking packing. Not an actual packing, that has additional logic regarding constraints and stackability, this focuses purely on fit. @param OrientatedItem $prevItem @param ItemList $nextItems @param int $originalWidthLeft @param int $originalLengthLeft @para...
[ "Approximation", "of", "a", "forward", "-", "looking", "packing", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/OrientatedItemFactory.php#L292-L325
dvdoug/BoxPacker
src/PackedBoxList.php
PackedBoxList.top
public function top(): PackedBox { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } return reset($this->list); }
php
public function top(): PackedBox { if (!$this->isSorted) { usort($this->list, [$this, 'compare']); $this->isSorted = true; } return reset($this->list); }
[ "public", "function", "top", "(", ")", ":", "PackedBox", "{", "if", "(", "!", "$", "this", "->", "isSorted", ")", "{", "usort", "(", "$", "this", "->", "list", ",", "[", "$", "this", ",", "'compare'", "]", ")", ";", "$", "this", "->", "isSorted",...
@internal @return PackedBox
[ "@internal" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBoxList.php#L91-L99
dvdoug/BoxPacker
src/PackedBoxList.php
PackedBoxList.compare
private function compare(PackedBox $boxA, PackedBox $boxB): int { $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); if ($choice === 0) { $choice = $boxB->getInnerVolume() <=> $boxA->getInnerVolume(); } if ($choice === 0) { $choice = $boxA->g...
php
private function compare(PackedBox $boxA, PackedBox $boxB): int { $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); if ($choice === 0) { $choice = $boxB->getInnerVolume() <=> $boxA->getInnerVolume(); } if ($choice === 0) { $choice = $boxA->g...
[ "private", "function", "compare", "(", "PackedBox", "$", "boxA", ",", "PackedBox", "$", "boxB", ")", ":", "int", "{", "$", "choice", "=", "$", "boxB", "->", "getItems", "(", ")", "->", "count", "(", ")", "<=>", "$", "boxA", "->", "getItems", "(", "...
@param PackedBox $boxA @param PackedBox $boxB @return int
[ "@param", "PackedBox", "$boxA", "@param", "PackedBox", "$boxB" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBoxList.php#L107-L118
dvdoug/BoxPacker
src/PackedBoxList.php
PackedBoxList.getMeanWeight
public function getMeanWeight(): float { $meanWeight = 0; /** @var PackedBox $box */ foreach ($this->list as $box) { $meanWeight += $box->getWeight(); } return $meanWeight / count($this->list); }
php
public function getMeanWeight(): float { $meanWeight = 0; /** @var PackedBox $box */ foreach ($this->list as $box) { $meanWeight += $box->getWeight(); } return $meanWeight / count($this->list); }
[ "public", "function", "getMeanWeight", "(", ")", ":", "float", "{", "$", "meanWeight", "=", "0", ";", "/** @var PackedBox $box */", "foreach", "(", "$", "this", "->", "list", "as", "$", "box", ")", "{", "$", "meanWeight", "+=", "$", "box", "->", "getWeig...
Calculate the average (mean) weight of the boxes. @return float
[ "Calculate", "the", "average", "(", "mean", ")", "weight", "of", "the", "boxes", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBoxList.php#L125-L135
dvdoug/BoxPacker
src/PackedBoxList.php
PackedBoxList.getWeightVariance
public function getWeightVariance(): float { $mean = $this->getMeanWeight(); $weightVariance = 0; /** @var PackedBox $box */ foreach ($this->list as $box) { $weightVariance += ($box->getWeight() - $mean) ** 2; } return round($weightVariance / count($this...
php
public function getWeightVariance(): float { $mean = $this->getMeanWeight(); $weightVariance = 0; /** @var PackedBox $box */ foreach ($this->list as $box) { $weightVariance += ($box->getWeight() - $mean) ** 2; } return round($weightVariance / count($this...
[ "public", "function", "getWeightVariance", "(", ")", ":", "float", "{", "$", "mean", "=", "$", "this", "->", "getMeanWeight", "(", ")", ";", "$", "weightVariance", "=", "0", ";", "/** @var PackedBox $box */", "foreach", "(", "$", "this", "->", "list", "as"...
Calculate the variance in weight between these boxes. @return float
[ "Calculate", "the", "variance", "in", "weight", "between", "these", "boxes", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBoxList.php#L142-L153
dvdoug/BoxPacker
src/PackedBoxList.php
PackedBoxList.getVolumeUtilisation
public function getVolumeUtilisation(): float { $itemVolume = 0; $boxVolume = 0; /** @var PackedBox $box */ foreach ($this as $box) { $boxVolume += $box->getInnerVolume(); /** @var PackedItem $item */ foreach ($box->getItems() as $item) { ...
php
public function getVolumeUtilisation(): float { $itemVolume = 0; $boxVolume = 0; /** @var PackedBox $box */ foreach ($this as $box) { $boxVolume += $box->getInnerVolume(); /** @var PackedItem $item */ foreach ($box->getItems() as $item) { ...
[ "public", "function", "getVolumeUtilisation", "(", ")", ":", "float", "{", "$", "itemVolume", "=", "0", ";", "$", "boxVolume", "=", "0", ";", "/** @var PackedBox $box */", "foreach", "(", "$", "this", "as", "$", "box", ")", "{", "$", "boxVolume", "+=", "...
Get volume utilisation of the set of packed boxes. @return float
[ "Get", "volume", "utilisation", "of", "the", "set", "of", "packed", "boxes", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedBoxList.php#L160-L176
dvdoug/BoxPacker
src/WeightRedistributor.php
WeightRedistributor.redistributeWeight
public function redistributeWeight(PackedBoxList $originalBoxes): PackedBoxList { $targetWeight = $originalBoxes->getMeanWeight(); $this->logger->log(LogLevel::DEBUG, "repacking for weight distribution, weight variance {$originalBoxes->getWeightVariance()}, target weight {$targetWeight}"); ...
php
public function redistributeWeight(PackedBoxList $originalBoxes): PackedBoxList { $targetWeight = $originalBoxes->getMeanWeight(); $this->logger->log(LogLevel::DEBUG, "repacking for weight distribution, weight variance {$originalBoxes->getWeightVariance()}, target weight {$targetWeight}"); ...
[ "public", "function", "redistributeWeight", "(", "PackedBoxList", "$", "originalBoxes", ")", ":", "PackedBoxList", "{", "$", "targetWeight", "=", "$", "originalBoxes", "->", "getMeanWeight", "(", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "LogLev...
Given a solution set of packed boxes, repack them to achieve optimum weight distribution. @param PackedBoxList $originalBoxes @return PackedBoxList
[ "Given", "a", "solution", "set", "of", "packed", "boxes", "repack", "them", "to", "achieve", "optimum", "weight", "distribution", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/WeightRedistributor.php#L56-L93
dvdoug/BoxPacker
src/WeightRedistributor.php
WeightRedistributor.equaliseWeight
private function equaliseWeight(PackedBox &$boxA, PackedBox &$boxB, float $targetWeight): bool { $anyIterationSuccessful = false; if ($boxA->getWeight() > $boxB->getWeight()) { $overWeightBox = $boxA; $underWeightBox = $boxB; } else { $overWeightBox = $bo...
php
private function equaliseWeight(PackedBox &$boxA, PackedBox &$boxB, float $targetWeight): bool { $anyIterationSuccessful = false; if ($boxA->getWeight() > $boxB->getWeight()) { $overWeightBox = $boxA; $underWeightBox = $boxB; } else { $overWeightBox = $bo...
[ "private", "function", "equaliseWeight", "(", "PackedBox", "&", "$", "boxA", ",", "PackedBox", "&", "$", "boxB", ",", "float", "$", "targetWeight", ")", ":", "bool", "{", "$", "anyIterationSuccessful", "=", "false", ";", "if", "(", "$", "boxA", "->", "ge...
Attempt to equalise weight distribution between 2 boxes. @param PackedBox $boxA @param PackedBox $boxB @param float $targetWeight @return bool was the weight rebalanced?
[ "Attempt", "to", "equalise", "weight", "distribution", "between", "2", "boxes", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/WeightRedistributor.php#L104-L152
dvdoug/BoxPacker
src/WeightRedistributor.php
WeightRedistributor.doVolumeRepack
private function doVolumeRepack(iterable $items): PackedBoxList { $packer = new Packer(); $packer->setBoxes($this->boxes); // use the full set of boxes to allow smaller/larger for full efficiency $packer->setItems($items); return $packer->doVolumePacking(); }
php
private function doVolumeRepack(iterable $items): PackedBoxList { $packer = new Packer(); $packer->setBoxes($this->boxes); // use the full set of boxes to allow smaller/larger for full efficiency $packer->setItems($items); return $packer->doVolumePacking(); }
[ "private", "function", "doVolumeRepack", "(", "iterable", "$", "items", ")", ":", "PackedBoxList", "{", "$", "packer", "=", "new", "Packer", "(", ")", ";", "$", "packer", "->", "setBoxes", "(", "$", "this", "->", "boxes", ")", ";", "// use the full set of ...
Do a volume repack of a set of items. @param iterable $items @return PackedBoxList
[ "Do", "a", "volume", "repack", "of", "a", "set", "of", "items", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/WeightRedistributor.php#L161-L168
dvdoug/BoxPacker
src/WeightRedistributor.php
WeightRedistributor.didRepackActuallyHelp
private function didRepackActuallyHelp(PackedBox $oldBoxA, PackedBox $oldBoxB, PackedBox $newBoxA, PackedBox $newBoxB): bool { $oldList = new PackedBoxList(); $oldList->insertFromArray([$oldBoxA, $oldBoxB]); $newList = new PackedBoxList(); $newList->insertFromArray([$newBoxA, $newBo...
php
private function didRepackActuallyHelp(PackedBox $oldBoxA, PackedBox $oldBoxB, PackedBox $newBoxA, PackedBox $newBoxB): bool { $oldList = new PackedBoxList(); $oldList->insertFromArray([$oldBoxA, $oldBoxB]); $newList = new PackedBoxList(); $newList->insertFromArray([$newBoxA, $newBo...
[ "private", "function", "didRepackActuallyHelp", "(", "PackedBox", "$", "oldBoxA", ",", "PackedBox", "$", "oldBoxB", ",", "PackedBox", "$", "newBoxA", ",", "PackedBox", "$", "newBoxB", ")", ":", "bool", "{", "$", "oldList", "=", "new", "PackedBoxList", "(", "...
Not every attempted repack is actually helpful - sometimes moving an item between two otherwise identical boxes, or sometimes the box used for the now lighter set of items actually weighs more when empty causing an increase in total weight. @param PackedBox $oldBoxA @param PackedBox $oldBoxB @param PackedBox $newBoxA ...
[ "Not", "every", "attempted", "repack", "is", "actually", "helpful", "-", "sometimes", "moving", "an", "item", "between", "two", "otherwise", "identical", "boxes", "or", "sometimes", "the", "box", "used", "for", "the", "now", "lighter", "set", "of", "items", ...
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/WeightRedistributor.php#L182-L191
dvdoug/BoxPacker
src/PackedItem.php
PackedItem.fromOrientatedItem
public static function fromOrientatedItem(OrientatedItem $orientatedItem, int $x, int $y, int $z): self { return new static( $orientatedItem->getItem(), $x, $y, $z, $orientatedItem->getWidth(), $orientatedItem->getLength(), ...
php
public static function fromOrientatedItem(OrientatedItem $orientatedItem, int $x, int $y, int $z): self { return new static( $orientatedItem->getItem(), $x, $y, $z, $orientatedItem->getWidth(), $orientatedItem->getLength(), ...
[ "public", "static", "function", "fromOrientatedItem", "(", "OrientatedItem", "$", "orientatedItem", ",", "int", "$", "x", ",", "int", "$", "y", ",", "int", "$", "z", ")", ":", "self", "{", "return", "new", "static", "(", "$", "orientatedItem", "->", "get...
@param OrientatedItem $orientatedItem @param int $x @param int $y @param int $z @return PackedItem
[ "@param", "OrientatedItem", "$orientatedItem", "@param", "int", "$x", "@param", "int", "$y", "@param", "int", "$z" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/PackedItem.php#L147-L158
dvdoug/BoxPacker
src/Packer.php
Packer.addItem
public function addItem(Item $item, int $qty = 1): void { for ($i = 0; $i < $qty; ++$i) { $this->items->insert($item); } $this->logger->log(LogLevel::INFO, "added {$qty} x {$item->getDescription()}", ['item' => $item]); }
php
public function addItem(Item $item, int $qty = 1): void { for ($i = 0; $i < $qty; ++$i) { $this->items->insert($item); } $this->logger->log(LogLevel::INFO, "added {$qty} x {$item->getDescription()}", ['item' => $item]); }
[ "public", "function", "addItem", "(", "Item", "$", "item", ",", "int", "$", "qty", "=", "1", ")", ":", "void", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "qty", ";", "++", "$", "i", ")", "{", "$", "this", "->", "items", ...
Add item to be packed. @param Item $item @param int $qty
[ "Add", "item", "to", "be", "packed", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L66-L72
dvdoug/BoxPacker
src/Packer.php
Packer.setItems
public function setItems(iterable $items): void { if ($items instanceof ItemList) { $this->items = clone $items; } else { $this->items = new ItemList(); foreach ($items as $item) { $this->items->insert($item); } } }
php
public function setItems(iterable $items): void { if ($items instanceof ItemList) { $this->items = clone $items; } else { $this->items = new ItemList(); foreach ($items as $item) { $this->items->insert($item); } } }
[ "public", "function", "setItems", "(", "iterable", "$", "items", ")", ":", "void", "{", "if", "(", "$", "items", "instanceof", "ItemList", ")", "{", "$", "this", "->", "items", "=", "clone", "$", "items", ";", "}", "else", "{", "$", "this", "->", "...
Set a list of items all at once. @param iterable $items
[ "Set", "a", "list", "of", "items", "all", "at", "once", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L79-L89
dvdoug/BoxPacker
src/Packer.php
Packer.addBox
public function addBox(Box $box): void { $this->boxes->insert($box); $this->logger->log(LogLevel::INFO, "added box {$box->getReference()}", ['box' => $box]); }
php
public function addBox(Box $box): void { $this->boxes->insert($box); $this->logger->log(LogLevel::INFO, "added box {$box->getReference()}", ['box' => $box]); }
[ "public", "function", "addBox", "(", "Box", "$", "box", ")", ":", "void", "{", "$", "this", "->", "boxes", "->", "insert", "(", "$", "box", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "LogLevel", "::", "INFO", ",", "\"added box {$box->ge...
Add box size. @param Box $box
[ "Add", "box", "size", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L96-L100
dvdoug/BoxPacker
src/Packer.php
Packer.pack
public function pack(): PackedBoxList { $packedBoxes = $this->doVolumePacking(); //If we have multiple boxes, try and optimise/even-out weight distribution if ($packedBoxes->count() > 1 && $packedBoxes->count() <= $this->maxBoxesToBalanceWeight) { $redistributor = new WeightRedi...
php
public function pack(): PackedBoxList { $packedBoxes = $this->doVolumePacking(); //If we have multiple boxes, try and optimise/even-out weight distribution if ($packedBoxes->count() > 1 && $packedBoxes->count() <= $this->maxBoxesToBalanceWeight) { $redistributor = new WeightRedi...
[ "public", "function", "pack", "(", ")", ":", "PackedBoxList", "{", "$", "packedBoxes", "=", "$", "this", "->", "doVolumePacking", "(", ")", ";", "//If we have multiple boxes, try and optimise/even-out weight distribution", "if", "(", "$", "packedBoxes", "->", "count",...
Pack items into boxes. @return PackedBoxList
[ "Pack", "items", "into", "boxes", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L137-L151
dvdoug/BoxPacker
src/Packer.php
Packer.doVolumePacking
public function doVolumePacking(): PackedBoxList { $packedBoxes = new PackedBoxList(); //Keep going until everything packed while ($this->items->count()) { $packedBoxesIteration = []; //Loop through boxes starting with smallest, see what happens foreach ...
php
public function doVolumePacking(): PackedBoxList { $packedBoxes = new PackedBoxList(); //Keep going until everything packed while ($this->items->count()) { $packedBoxesIteration = []; //Loop through boxes starting with smallest, see what happens foreach ...
[ "public", "function", "doVolumePacking", "(", ")", ":", "PackedBoxList", "{", "$", "packedBoxes", "=", "new", "PackedBoxList", "(", ")", ";", "//Keep going until everything packed", "while", "(", "$", "this", "->", "items", "->", "count", "(", ")", ")", "{", ...
Pack items into boxes using the principle of largest volume item first. @throws ItemTooLargeException @return PackedBoxList
[ "Pack", "items", "into", "boxes", "using", "the", "principle", "of", "largest", "volume", "item", "first", "." ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L160-L195
dvdoug/BoxPacker
src/Packer.php
Packer.findBestBoxFromIteration
private function findBestBoxFromIteration($packedBoxes): PackedBox { //Check iteration was productive if (count($packedBoxes) === 0) { throw new ItemTooLargeException('Item ' . $this->items->top()->getDescription() . ' is too large to fit into any box', $this->items->top()); } ...
php
private function findBestBoxFromIteration($packedBoxes): PackedBox { //Check iteration was productive if (count($packedBoxes) === 0) { throw new ItemTooLargeException('Item ' . $this->items->top()->getDescription() . ' is too large to fit into any box', $this->items->top()); } ...
[ "private", "function", "findBestBoxFromIteration", "(", "$", "packedBoxes", ")", ":", "PackedBox", "{", "//Check iteration was productive", "if", "(", "count", "(", "$", "packedBoxes", ")", "===", "0", ")", "{", "throw", "new", "ItemTooLargeException", "(", "'Item...
@param PackedBox[] $packedBoxes @return PackedBox
[ "@param", "PackedBox", "[]", "$packedBoxes" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L202-L212
dvdoug/BoxPacker
src/Packer.php
Packer.compare
private static function compare(PackedBox $boxA, PackedBox $boxB): int { $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); if ($choice === 0) { $choice = $boxB->getVolumeUtilisation() <=> $boxA->getVolumeUtilisation(); } if ($choice === 0) { ...
php
private static function compare(PackedBox $boxA, PackedBox $boxB): int { $choice = $boxB->getItems()->count() <=> $boxA->getItems()->count(); if ($choice === 0) { $choice = $boxB->getVolumeUtilisation() <=> $boxA->getVolumeUtilisation(); } if ($choice === 0) { ...
[ "private", "static", "function", "compare", "(", "PackedBox", "$", "boxA", ",", "PackedBox", "$", "boxB", ")", ":", "int", "{", "$", "choice", "=", "$", "boxB", "->", "getItems", "(", ")", "->", "count", "(", ")", "<=>", "$", "boxA", "->", "getItems"...
@param PackedBox $boxA @param PackedBox $boxB @return int
[ "@param", "PackedBox", "$boxA", "@param", "PackedBox", "$boxB" ]
train
https://github.com/dvdoug/BoxPacker/blob/738fab0b4599cc036790ad4b42faa1aaef6f9f89/src/Packer.php#L220-L235
phpro/soap-client
src/Phpro/SoapClient/CodeGenerator/Assembler/ResultAssembler.php
ResultAssembler.assemble
public function assemble(ContextInterface $context) { try { $interfaceAssembler = new InterfaceAssembler(ResultInterface::class); if ($interfaceAssembler->canAssemble($context)) { $interfaceAssembler->assemble($context); } } catch (\Exception $e) {...
php
public function assemble(ContextInterface $context) { try { $interfaceAssembler = new InterfaceAssembler(ResultInterface::class); if ($interfaceAssembler->canAssemble($context)) { $interfaceAssembler->assemble($context); } } catch (\Exception $e) {...
[ "public", "function", "assemble", "(", "ContextInterface", "$", "context", ")", "{", "try", "{", "$", "interfaceAssembler", "=", "new", "InterfaceAssembler", "(", "ResultInterface", "::", "class", ")", ";", "if", "(", "$", "interfaceAssembler", "->", "canAssembl...
@param ContextInterface|TypeContext $context @throws AssemblerException
[ "@param", "ContextInterface|TypeContext", "$context" ]
train
https://github.com/phpro/soap-client/blob/5d963557b5e4a845000bb7558d2d2b0d78357e9b/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultAssembler.php#L30-L40
phpro/soap-client
src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php
TypeConverterCollection.add
public function add(TypeConverterInterface $converter): self { if ($this->has($converter)) { throw new InvalidArgumentException( 'Converter for this type already exists' ); } return $this->set($converter); }
php
public function add(TypeConverterInterface $converter): self { if ($this->has($converter)) { throw new InvalidArgumentException( 'Converter for this type already exists' ); } return $this->set($converter); }
[ "public", "function", "add", "(", "TypeConverterInterface", "$", "converter", ")", ":", "self", "{", "if", "(", "$", "this", "->", "has", "(", "$", "converter", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Converter for this type already exi...
Add a type converter to the collection @param TypeConverterInterface $converter Type converter @return TypeConverterCollection @throws InvalidArgumentException
[ "Add", "a", "type", "converter", "to", "the", "collection" ]
train
https://github.com/phpro/soap-client/blob/5d963557b5e4a845000bb7558d2d2b0d78357e9b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php#L46-L55
phpro/soap-client
src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php
TypeConverterCollection.set
public function set(TypeConverterInterface $converter): self { $serialized = $this->serialize($converter); $this->converters[$serialized] = $converter; return $this; }
php
public function set(TypeConverterInterface $converter): self { $serialized = $this->serialize($converter); $this->converters[$serialized] = $converter; return $this; }
[ "public", "function", "set", "(", "TypeConverterInterface", "$", "converter", ")", ":", "self", "{", "$", "serialized", "=", "$", "this", "->", "serialize", "(", "$", "converter", ")", ";", "$", "this", "->", "converters", "[", "$", "serialized", "]", "=...
Set (overwrite) a type converter in the collection @param TypeConverterInterface $converter Type converter @return TypeConverterCollection
[ "Set", "(", "overwrite", ")", "a", "type", "converter", "in", "the", "collection" ]
train
https://github.com/phpro/soap-client/blob/5d963557b5e4a845000bb7558d2d2b0d78357e9b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php#L64-L70
phpro/soap-client
src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php
TypeConverterCollection.has
public function has(TypeConverterInterface $converter): bool { $serialized = $this->serialize($converter); if (isset($this->converters[$serialized])) { return true; } return false; }
php
public function has(TypeConverterInterface $converter): bool { $serialized = $this->serialize($converter); if (isset($this->converters[$serialized])) { return true; } return false; }
[ "public", "function", "has", "(", "TypeConverterInterface", "$", "converter", ")", ":", "bool", "{", "$", "serialized", "=", "$", "this", "->", "serialize", "(", "$", "converter", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "converters", "[", ...
Returns true if the collection contains a type converter for a certain namespace and name @param TypeConverterInterface $converter @return bool
[ "Returns", "true", "if", "the", "collection", "contains", "a", "type", "converter", "for", "a", "certain", "namespace", "and", "name" ]
train
https://github.com/phpro/soap-client/blob/5d963557b5e4a845000bb7558d2d2b0d78357e9b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php#L80-L88
phpro/soap-client
src/Phpro/SoapClient/Console/Helper/ConfigHelper.php
ConfigHelper.load
public function load(InputInterface $input): ConfigInterface { $configFile = $input->getOption('config'); if (!$configFile || !$this->filesystem->fileExists($configFile)) { throw InvalidArgumentException::invalidConfigFile(); } $config = include $configFile; if (!...
php
public function load(InputInterface $input): ConfigInterface { $configFile = $input->getOption('config'); if (!$configFile || !$this->filesystem->fileExists($configFile)) { throw InvalidArgumentException::invalidConfigFile(); } $config = include $configFile; if (!...
[ "public", "function", "load", "(", "InputInterface", "$", "input", ")", ":", "ConfigInterface", "{", "$", "configFile", "=", "$", "input", "->", "getOption", "(", "'config'", ")", ";", "if", "(", "!", "$", "configFile", "||", "!", "$", "this", "->", "f...
Attempts to load the configuration file, returns it on success @param InputInterface $input @return Config
[ "Attempts", "to", "load", "the", "configuration", "file", "returns", "it", "on", "success" ]
train
https://github.com/phpro/soap-client/blob/5d963557b5e4a845000bb7558d2d2b0d78357e9b/src/Phpro/SoapClient/Console/Helper/ConfigHelper.php#L38-L50