_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q258900
Note.getModelClassAndId
test
protected function getModelClassAndId() { $oInput = Factory::service('Input'); $sModelName = $oInput->get('model_name') ?: $oInput->post('model_name'); $sModelProvider = $oInput->get('model_provider') ?: $oInput->post('model_provider'); $iItemId = (int) $oInput->ge...
php
{ "resource": "" }
q258901
Note.formatObject
test
protected function formatObject($oObj) { return (object) [ 'id' => $oObj->id, 'message' => auto_typography($oObj->message), 'date' => toUserDatetime($oObj->created), 'user' => (object) [ 'id' => $oObj->created_by ? (int) $oOb...
php
{ "resource": "" }
q258902
SimpleCalendar.setDate
test
public function setDate( $date_string = null ) { if( $date_string ) { $this->now = getdate(strtotime($date_string)); } else { $this->now = getdate(); } }
php
{ "resource": "" }
q258903
SimpleCalendar.addDailyHtml
test
public function addDailyHtml( $html, $start_date_string, $end_date_string = null ) { static $htmlCount = 0; $start_date = strtotime($start_date_string); if( $end_date_string ) { $end_date = strtotime($end_date_string); } else { $end_date = $start_date; } $working_date = $start_date; do { $tDate ...
php
{ "resource": "" }
q258904
SimpleCalendar.setStartOfWeek
test
public function setStartOfWeek( $offset ) { if( is_int($offset) ) { $this->offset = $offset % 7; } else { $this->offset = date('N', strtotime($offset)) % 7; } }
php
{ "resource": "" }
q258905
Debug.p
test
public static function p($str, $args = false) { if (self::$_debug === true || ApiConfig::get('debug') === true) { // first call if (self::$_debug === false) { self::$_debug = true; } if ($args !== false) { $str .= ', dump: ' . ...
php
{ "resource": "" }
q258906
Payments.submitBonus
test
public function submitBonus($teamReference, $params) { ApiDebug::p(__FUNCTION__); $adjustments = $this->_client->post('/hr/v2/teams/' . $teamReference . '/adjustments', $params); ApiDebug::p('found adjustments info', $adjustments); return $adjustments; }
php
{ "resource": "" }
q258907
Engagement.assign
test
public function assign($company, $team, $engagement, $params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->put('/otask/v1/tasks/companies/' .$company . '/teams/' . $team . '/engagements/' . $engagement . '/tasks', $params); ApiDebug::p('found response info', $response); ...
php
{ "resource": "" }
q258908
Engagement.assignToEngagement
test
public function assignToEngagement($engagement, $params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->put('/tasks/v2/tasks/contracts/' . $engagement, $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258909
Earnings.getByFreelancer
test
public function getByFreelancer($freelancerReference, $params) { ApiDebug::p(__FUNCTION__); $report = $this->_client->get('/finreports/v2/providers/' . $freelancerReference . '/earnings', $params); ApiDebug::p('found report info', $report); return $report; }
php
{ "resource": "" }
q258910
Earnings.getByFreelancersTeam
test
public function getByFreelancersTeam($freelancerTeamReference, $params) { ApiDebug::p(__FUNCTION__); $report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/earnings', $params); ApiDebug::p('found report info', $report); return $report; }
php
{ "resource": "" }
q258911
Earnings.getByFreelancersCompany
test
public function getByFreelancersCompany($freelancerCompanyReference, $params) { ApiDebug::p(__FUNCTION__); $report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/earnings', $params); ApiDebug::p('found report info', $report); return $re...
php
{ "resource": "" }
q258912
Earnings.getByBuyersTeam
test
public function getByBuyersTeam($buyerTeamReference, $params) { ApiDebug::p(__FUNCTION__); $report = $this->_client->get('/finreports/v2/buyer_teams/' . $buyerTeamReference . '/earnings', $params); ApiDebug::p('found report info', $report); return $report; }
php
{ "resource": "" }
q258913
Earnings.getByBuyersCompany
test
public function getByBuyersCompany($buyerCompanyReference, $params) { ApiDebug::p(__FUNCTION__); $report = $this->_client->get('/finreports/v2/buyer_companies/' . $buyerCompanyReference . '/earnings', $params); ApiDebug::p('found report info', $report); return $report; }
php
{ "resource": "" }
q258914
Engagements.getList
test
public function getList($params) { ApiDebug::p(__FUNCTION__); $engagements = $this->_client->get('/hr/v2/engagements', $params); ApiDebug::p('found response info', $engagements); return $engagements; }
php
{ "resource": "" }
q258915
Engagements.getSpecific
test
public function getSpecific($reference) { ApiDebug::p(__FUNCTION__); $engagement = $this->_client->get('/hr/v2/engagements/' . $reference); ApiDebug::p('found response info', $engagement); return $engagement; }
php
{ "resource": "" }
q258916
Utils.getFullUrl
test
static public function getFullUrl($url, $ep = null) { ApiDebug::p('create full url, based on global constant'); $name = ($ep) ? 'UPWORK_BASE_URL_' . strtoupper($ep) : 'UPWORK_BASE_URL'; $fullUrl = constant($name) . $url; ApiDebug::p('url', $fullUrl); ...
php
{ "resource": "" }
q258917
Offers.getList
test
public function getList($params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/offers/v1/contractors/offers', $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258918
Offers.actions
test
public function actions($reference, $params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->post('/offers/v1/contractors/actions/' . $reference, $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258919
Accounts.getSpecific
test
public function getSpecific($entityReference, $params) { ApiDebug::p(__FUNCTION__); $report = $this->_client->get('/finreports/v2/financial_accounts/' . $entityReference, $params); ApiDebug::p('found auth info', $report); return $report; }
php
{ "resource": "" }
q258920
Roles.getAll
test
public function getAll() { ApiDebug::p(__FUNCTION__); $roles = $this->_client->get('/hr/v2/userroles'); ApiDebug::p('found response info', $roles); return $roles; }
php
{ "resource": "" }
q258921
Roles.getBySpecificUser
test
public function getBySpecificUser($reference) { ApiDebug::p(__FUNCTION__); $roles = $this->_client->get('/hr/v2/userroles/' . $reference); ApiDebug::p('found auth info', $roles); return $roles; }
php
{ "resource": "" }
q258922
Interviews.invite
test
public function invite($jobKey, $params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->post('/hr/v1/jobs/' . $jobKey . '/candidates', $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258923
Time.getByAgency
test
public function getByAgency($company, $agency, $params) { ApiDebug::p(__FUNCTION__); return $this->_getByType($company, null, $agency, $params); }
php
{ "resource": "" }
q258924
Time.getByCompany
test
public function getByCompany($company, $params) { ApiDebug::p(__FUNCTION__); return $this->_getByType($company, null, null, $params); }
php
{ "resource": "" }
q258925
Teams.getUsersInTeam
test
public function getUsersInTeam($teamReference) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/hr/v2/teams/' . $teamReference . '/users'); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258926
Jobs.getList
test
public function getList($params) { ApiDebug::p(__FUNCTION__); $jobs = $this->_client->get('/hr/v2/jobs', $params); ApiDebug::p('found response info', $jobs); return $jobs; }
php
{ "resource": "" }
q258927
Jobs.getSpecific
test
public function getSpecific($key) { ApiDebug::p(__FUNCTION__); $job = $this->_client->get('/hr/v2/jobs/' . $key); ApiDebug::p('found response info', $job); return $job; }
php
{ "resource": "" }
q258928
Jobs.postJob
test
public function postJob($params) { ApiDebug::p(__FUNCTION__); $job = $this->_client->post('/hr/v2/jobs', $params); ApiDebug::p('found response info', $job); return $job; }
php
{ "resource": "" }
q258929
Jobs.editJob
test
public function editJob($key, $params) { ApiDebug::p(__FUNCTION__); $job = $this->_client->put('/hr/v2/jobs/' . $key, $params); ApiDebug::p('found response info', $job); return $job; }
php
{ "resource": "" }
q258930
Jobs.deleteJob
test
public function deleteJob($key, $params) { ApiDebug::p(__FUNCTION__); $job = $this->_client->delete('/hr/v2/jobs/' . $key, $params); ApiDebug::p('found response info', $job); return $job; }
php
{ "resource": "" }
q258931
Users.getMyInfo
test
public function getMyInfo() { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/hr/v2/users/me'); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258932
Users.getSpecific
test
public function getSpecific($userReference) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/hr/v2/users/' . $userReference); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258933
Team._getByType
test
private function _getByType($company, $team, $code = null) { ApiDebug::p(__FUNCTION__); $_url = ''; if (!empty($code)) { $_url = '/' . $code; } $response = $this->_client->get('/otask/v1/tasks/companies/' . $company . '/teams/' . $team . '/tasks' . $_url); ...
php
{ "resource": "" }
q258934
Messages.getRoomDetails
test
public function getRoomDetails($company, $roomId, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/messages/v3/' . $company . '/rooms/' . $roomId, $params); ApiDebug::p('received data', $response); return $response; }
php
{ "resource": "" }
q258935
Messages.getRoomByOffer
test
public function getRoomByOffer($company, $offerId, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/messages/v3/' . $company . '/rooms/offers/' . $offerId, $params); ApiDebug::p('received data', $response); return $response; }
php
{ "resource": "" }
q258936
Messages.getRoomByApplication
test
public function getRoomByApplication($company, $applicationId, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/messages/v3/' . $company . '/rooms/applications/' . $applicationId, $params); ApiDebug::p('received data', $response); return $response; ...
php
{ "resource": "" }
q258937
Messages.getRoomByContract
test
public function getRoomByContract($company, $contractId, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/messages/v3/' . $company . '/rooms/contracts/' . $contractId, $params); ApiDebug::p('received data', $response); return $response; }
php
{ "resource": "" }
q258938
Messages.createRoom
test
public function createRoom($company, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->post('/messages/v3/' . $company . '/rooms', $params); ApiDebug::p('received data', $response); return $response; }
php
{ "resource": "" }
q258939
Messages.sendMessageToRoom
test
public function sendMessageToRoom($company, $roomId, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->post('/messages/v3/' . $company . '/rooms/' . $roomId . '/stories', $params); ApiDebug::p('received data', $response); return $response; }
php
{ "resource": "" }
q258940
Messages.updateRoomSettings
test
public function updateRoomSettings($company, $roomId, $username, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->put('/messages/v3/' . $company . '/rooms/' . $roomId . '/users/' . $username, $params); ApiDebug::p('received data', $response); return $resp...
php
{ "resource": "" }
q258941
Messages.updateRoomMetadata
test
public function updateRoomMetadata($company, $roomId, $params = array()) { ApiDebug::p(__FUNCTION__); $response = $this->_client->put('/messages/v3/' . $company . '/rooms/' . $roomId, $params); ApiDebug::p('received data', $response); return $response; }
php
{ "resource": "" }
q258942
Snapshot.getByContract
test
public function getByContract($contractId, $ts) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/team/v3/snapshots/contracts/' . $contractId . '/' . $ts); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258943
Snapshot.updateByContract
test
public function updateByContract($contractId, $ts, $params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->put('/team/v3/snapshots/contracts/' . $contractId . '/' . $ts, $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258944
Snapshot.deleteByContract
test
public function deleteByContract($contractId, $ts) { ApiDebug::p(__FUNCTION__); $response = $this->_client->delete('/team/v3/snapshots/contracts/' . $contractId . '/' . $ts); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258945
Milestones.getActiveMilestone
test
public function getActiveMilestone($contractId) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/hr/v3/fp/milestones/statuses/active/contracts/' . $contractId); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258946
Milestones.getSubmissions
test
public function getSubmissions($milestoneId) { ApiDebug::p(__FUNCTION__); $response = $this->_client->get('/hr/v3/fp/milestones/' . $milestoneId . '/submissions'); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258947
Milestones.create
test
public function create($params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->post('/hr/v3/fp/milestones', $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258948
Milestones.edit
test
public function edit($milestoneId, $params) { ApiDebug::p(__FUNCTION__); $response = $this->_client->put('/hr/v3/fp/milestones/' . $milestoneId, $params); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258949
Milestones.delete
test
public function delete($milestoneId) { ApiDebug::p(__FUNCTION__); $response = $this->_client->delete('/hr/v3/fp/milestones/' . $milestoneId); ApiDebug::p('found response info', $response); return $response; }
php
{ "resource": "" }
q258950
Client._request
test
protected function _request($type, $url, $params = array()) { ApiDebug::p('running Client request', $this->_server); $method = 'POST'; switch ($type) { case 'PUT': $params['http_method'] = 'put'; break; case 'DELETE': $...
php
{ "resource": "" }
q258951
FacebookAccountKitServiceProvider.boot
test
public function boot() { $config = realpath(__DIR__ . '/../resources/config/accountKit.php'); $js = realpath(__DIR__ . '/../resources/config/accountkit.js'); $this->publishes([ $config => config_path('accountKit.php') ], 'config'); $this->publishes([ ...
php
{ "resource": "" }
q258952
AccountKit.getContentBody
test
private function getContentBody($url) { $data = $this->client->request('GET', $url); return json_decode($data->getBody()); }
php
{ "resource": "" }
q258953
FacebookAccountKit.accountKitData
test
public function accountKitData($code) { $data = $this->data($code); $output = [ 'id' => $data->id, 'phoneNumber' => '', 'email' => '', ]; if (array_key_exists('phone', $data)) { $output['phoneNumber'] = $data->phone->number ?? null; ...
php
{ "resource": "" }
q258954
ContactResourceController.index
test
public function index(ContactRequest $request) { if ($this->response->typeIs('json')) { $pageLimit = $request->input('pageLimit'); $data = $this->repository ->setPresenter(\Litecms\Contact\Repositories\Presenter\ContactListPresenter::class) ->get...
php
{ "resource": "" }
q258955
ContactResourceController.show
test
public function show(ContactRequest $request, Contact $contact) { if ($contact->exists) { $view = 'contact::contact.show'; } else { $view = 'contact::contact.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('contact::contact.name'...
php
{ "resource": "" }
q258956
ContactResourceController.create
test
public function create(ContactRequest $request) { $contact = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('contact::contact.name')) ->view('contact::contact.create', true) ->data(compact('contact')) ->o...
php
{ "resource": "" }
q258957
ContactResourceController.edit
test
public function edit(ContactRequest $request, Contact $contact) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('contact::contact.name')) ->view('contact::contact.edit', true) ->data(compact('contact')) ->output(); }
php
{ "resource": "" }
q258958
ContactResourceController.update
test
public function update(ContactRequest $request, Contact $contact) { try { $attributes = $request->all(); $contact->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('contact::contact.name')])) ->code...
php
{ "resource": "" }
q258959
ContactResourceController.destroy
test
public function destroy(ContactRequest $request, Contact $contact) { try { $contact->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('contact::contact.name')])) ->code(202) ->status('success') ...
php
{ "resource": "" }
q258960
Contact.gadget
test
public function gadget($view = 'admin.contact.gadget', $count = 10) { if (User::hasRole('user')) { $this->contact->pushCriteria(new \Litecms\Litecms\Repositories\Criteria\ContactUserCriteria()); } $contact = $this->contact->scopeQuery(function ($query) use ($count) { ...
php
{ "resource": "" }
q258961
Contact.get
test
public function get($field) { $data= $this->contact->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->first([$field]); return $data[$field]; }
php
{ "resource": "" }
q258962
ContactPolicy.view
test
public function view(User $user, Contact $contact) { if ($user->canDo('contact.contact.view') && $user->isAdmin()) { return true; } }
php
{ "resource": "" }
q258963
ContactPolicy.update
test
public function update(User $user, Contact $contact) { if ($user->canDo('contact.contact.update') && $user->isAdmin()) { return true; } }
php
{ "resource": "" }
q258964
ContactPolicy.destroy
test
public function destroy(User $user, Contact $contact) { if ($user->canDo('contact.contact.delete') && $user->isAdmin()) { return true; } }
php
{ "resource": "" }
q258965
ContactPublicController.index
test
protected function index() { $this->response->theme->asset()->container('footer')->add('gmap', 'https://maps.googleapis.com/maps/api/js?key=' . config('litecms.contact.gmapapi')); $contact = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ...
php
{ "resource": "" }
q258966
HtmlParser.parseHtml
test
protected function parseHtml(LinkInterface $link) { $images = []; try { $parser = new Crawler(); $parser->addHtmlContent($link->getContent()); // Parse all known tags foreach($this->tags as $tag => $selectors) { foreach($selectors as $select...
php
{ "resource": "" }
q258967
Client.getPreviews
test
public function getPreviews() { $parsed = []; foreach ($this->getParsers() as $name => $parser) { if ($parser->canParseLink($this->link)) $parsed[$name] = $parser->parseLink($this->link)->getPreview(); } return $parsed; }
php
{ "resource": "" }
q258968
Client.getPreview
test
public function getPreview($parserId) { if (array_key_exists($parserId, $this->getParsers())) { $parser = $this->getParsers()[$parserId]; } else throw new UnknownParserException(); return $parser->parseLink($this->link)->getPreview(); }
php
{ "resource": "" }
q258969
Client.addParser
test
public function addParser(ParserInterface $parser) { $this->parsers = [(string) $parser => $parser] + $this->parsers; return $this; }
php
{ "resource": "" }
q258970
Client.removeParser
test
public function removeParser($name) { if (in_array($name, $this->parsers, false)) { unset($this->parsers[$name]); } return $this; }
php
{ "resource": "" }
q258971
Client.addDefaultParsers
test
protected function addDefaultParsers() { $this->addParser(new HtmlParser()); $this->addParser(new YouTubeParser()); $this->addParser(new VimeoParser()); }
php
{ "resource": "" }
q258972
Color.contrastFromHex
test
public function contrastFromHex($hex) { $hash = ''; if (substr($hex, 0, 1) === '#') { $hash = '#'; $hex = substr($hex, 1); } $color = $this->contrastFromRGB(...sscanf($hex, '%02x%02x%02x')); return sprintf('%s%02x%02x%02x', $hash, $color['r'], $colo...
php
{ "resource": "" }
q258973
FileSystem.enclosePath
test
public function enclosePath($path) { // Add starting slash. if (substr($path, 0, 1) !== '/') { $path = '/'.$path; } // Add trailing slash. if (substr($path, -1, 1) !== '/') { $path .= '/'; } return $path; }
php
{ "resource": "" }
q258974
Database.convertInterval
test
public function convertInterval($interval) { switch (strtolower($interval)) { case 'y': case 'year': $interval = 'YEAR'; break; case 'm': case 'month': $interval = 'MONTH'; break; case...
php
{ "resource": "" }
q258975
MacroServiceProvider.boot
test
public function boot() { // Providesd the ability to download a file from a given path. // Will also return a not modified header if file has not changed. Response::macro('downloadAndCache', function ($file_path) { if (!empty(request()->header('If-Modified-Since'))) { ...
php
{ "resource": "" }
q258976
Timezone.data
test
public static function data($config = []) { foreach (self::$regions as $region => $mask) { $zones = DateTimeZone::listIdentifiers($mask); foreach ($zones as $timezone) { // Time at this timezone. $time = Carbon::now($timezone); // Co...
php
{ "resource": "" }
q258977
Timezone.optionsArray
test
public static function optionsArray($config = []) { $data = self::data($config); $result = []; foreach ($data as $name => $zones) { if (array_get($config, 'include-region', false)) { $result[] = [array_get($config, 'region-value', null), $name]; } ...
php
{ "resource": "" }
q258978
LaravelModel.getModelRelation
test
private function getModelRelation($relation) { $method = basename(str_replace('\\', '/', get_class($relation))); switch ($method) { case 'BelongsTo': case 'HasMany': case 'HasOne': $model = $relation->getRelated(); break; ...
php
{ "resource": "" }
q258979
LaravelModel.modelJoin
test
public function modelJoin(&$query, &$primary_model, &$relationships, $operator = '=', $type = 'left', $where = false) { if (is_string($relationships)) { $relationships = [$relationships => []]; } if (!is_array($relationships)) { $relationships = [$relationships]; ...
php
{ "resource": "" }
q258980
Aws.client
test
public function client($override = []) { return [ 'version' => array_get($override, 'version', config('hnhdigital.aws.version')), 'region' => array_get($override, 'region', config('hnhdigital.aws.region')), 'credentials' => [ 'key' => array_get...
php
{ "resource": "" }
q258981
SemanticVersion.toNumber
test
public static function toNumber($value) { $version_array = explode('-', $value, 2); $version = array_pad(explode('.', $version_array[0]), 4, '00000'); $version_extra = array_get($version_array, 1, ''); if (strlen($version[0]) == 8) { $version_number = (int) $version[0] *...
php
{ "resource": "" }
q258982
JobTrait.scopeLookupKeyValue
test
public function scopeLookupKeyValue($query, $key, $value, $class_name = '', $data_type = 's') { // Lookup serialized array. if (is_array($value)) { $value = serialize($value); $value = self::encodeQueryValue(addslashes($value)); $sql = sprintf( 'p...
php
{ "resource": "" }
q258983
JobTrait.setAvailableAtAttribute
test
public function setAvailableAtAttribute($value) { $this->attributes['available_at'] = empty($value) ? 0 : $this->asDateTime($value)->timestamp; return $this; }
php
{ "resource": "" }
q258984
JobTrait.getPayloadAttribute
test
public function getPayloadAttribute($value) { $value = json_decode($value); data_set($value, 'data.command', unserialize(data_get($value, 'data.command'))); return $value; }
php
{ "resource": "" }
q258985
Human.bytes
test
public function bytes($bytes, $decimals = 2, $mod = 1024) { $factor = floor((strlen($bytes) - 1) / 3); $byte_name = $this->units_of_bytes[$factor]; if ($mod == 1000) { $byte_name = str_replace('B', 'bit', $byte_name); } return sprintf("%.{$decimals}f %s", $bytes ...
php
{ "resource": "" }
q258986
Human.timeOffset
test
public function timeOffset($offset) { $offset_whole = round($offset); $offset_decimal = abs($offset - $offset_whole) * 60; return (substr($offset, 0, 1) != '-' ? '+' : '').$offset_whole.':'.str_pad($offset_decimal, 2, '0', STR_PAD_LEFT); }
php
{ "resource": "" }
q258987
Human.seconds
test
public function seconds($seconds, $options = []) { // Seconds. if ($seconds < 60) { $time = $seconds; $name = 'second'; } // Minutes. if ($seconds >= 60) { $time = round($seconds / 60, 0); $name = 'minute'; } /...
php
{ "resource": "" }
q258988
Human.truncate
test
public function truncate($long_text, $length, $options = []) { $short_text = mb_substr($long_text, 0, $length); if ($short_text === $long_text) { return $long_text; } $short_text .= '...'; if (array_get($options, 'html', false)) { $short_text .= ' <...
php
{ "resource": "" }
q258989
AmazonSNS.addPermission
test
public function addPermission($topicArn, $label, $permissions = array()) { if(empty($topicArn) || empty($label)) { throw new InvalidArgumentException('Must supply TopicARN and a Label for this permission'); } // Add standard params as normal $params = array( 'TopicArn' => $topicArn, 'Label' => $label ...
php
{ "resource": "" }
q258990
AmazonSNS.confirmSubscription
test
public function confirmSubscription($topicArn, $token, $authenticateOnUnsubscribe = null) { if(empty($topicArn) || empty($token)) { throw new InvalidArgumentException('Must supply a TopicARN and a Token to confirm subscription'); } $params = array( 'TopicArn' => $topicArn, 'Token' => $token ); if(!...
php
{ "resource": "" }
q258991
AmazonSNS.createTopic
test
public function createTopic($name) { if(empty($name)) { throw new InvalidArgumentException('Must supply a Name to create topic'); } $resultXml = $this->_request('CreateTopic', array('Name' => $name)); return strval($resultXml->CreateTopicResult->TopicArn); }
php
{ "resource": "" }
q258992
AmazonSNS.getTopicAttributes
test
public function getTopicAttributes($topicArn) { if(empty($topicArn)) { throw new InvalidArgumentException('Must supply a TopicARN to get topic attributes'); } $resultXml = $this->_request('GetTopicAttributes', array('TopicArn' => $topicArn)); // Get attributes $attributes = $resultXml->GetTopicAttributes...
php
{ "resource": "" }
q258993
AmazonSNS.listSubscriptions
test
public function listSubscriptions($nextToken = null) { $params = array(); if(!is_null($nextToken)) { $params['NextToken'] = $nextToken; } $resultXml = $this->_request('ListSubscriptions', $params); // Get subscriptions $subs = $resultXml->ListSubscriptionsResult->Subscriptions->member; $return = ['...
php
{ "resource": "" }
q258994
AmazonSNS.listSubscriptionsByTopic
test
public function listSubscriptionsByTopic($topicArn, $nextToken = null) { if(empty($topicArn)) { throw new InvalidArgumentException('Must supply a TopicARN to show subscriptions to a topic'); } $params = array( 'TopicArn' => $topicArn ); if(!is_null($nextToken)) { $params['NextToken'] = $nextToken; ...
php
{ "resource": "" }
q258995
AmazonSNS.listTopics
test
public function listTopics($nextToken = null) { $params = array(); if(!is_null($nextToken)) { $params['NextToken'] = $nextToken; } $resultXml = $this->_request('ListTopics', $params); // Get Topics $topics = $resultXml->ListTopicsResult->Topics->member; return $this->_processXmlToArray($topics); }
php
{ "resource": "" }
q258996
AmazonSNS.publish
test
public function publish($topicArn, $message, $subject = '', $messageStructure = '') { if(empty($topicArn) || empty($message)) { throw new InvalidArgumentException('Must supply a TopicARN and Message to publish to a topic'); } $params = array( 'TopicArn' => $topicArn, 'Message' => $message ); if(!em...
php
{ "resource": "" }
q258997
AmazonSNS.removePermission
test
public function removePermission($topicArn, $label) { if(empty($topicArn) || empty($label)) { throw new InvalidArgumentException('Must supply a TopicARN and Label to remove a permission'); } $this->_request('RemovePermission', array('Label' => $label)); return true; }
php
{ "resource": "" }
q258998
AmazonSNS.setTopicAttributes
test
public function setTopicAttributes($topicArn, $attrName, $attrValue) { if(empty($topicArn) || empty($attrName) || empty($attrValue)) { throw new InvalidArgumentException('Must supply a TopicARN, AttributeName and AttributeValue to set a topic attribute'); } $this->_request('SetTopicAttributes', array( 'Top...
php
{ "resource": "" }
q258999
AmazonSNS.subscribe
test
public function subscribe($topicArn, $protocol, $endpoint) { if(empty($topicArn) || empty($protocol) || empty($endpoint)) { throw new InvalidArgumentException('Must supply a TopicARN, Protocol and Endpoint to subscribe to a topic'); } $response = $this->_request('Subscribe', array( 'TopicArn' => $topicArn,...
php
{ "resource": "" }