repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
azine/email-bundle
Services/AzineTwigSwiftMailer.php
AzineTwigSwiftMailer.sendUpdateEmailConfirmation
public function sendUpdateEmailConfirmation(UserInterface $user, $confirmationUrl, $toEmail) { $template = $this->parameters['template']['email_updating']; $fromEmail = $this->parameters['from_email']['confirmation']; $context = array( 'user' => $user, 'confirmationUrl' => $confirmationUrl, ); $this->sendMessage($template, $context, $fromEmail, $toEmail); }
php
public function sendUpdateEmailConfirmation(UserInterface $user, $confirmationUrl, $toEmail) { $template = $this->parameters['template']['email_updating']; $fromEmail = $this->parameters['from_email']['confirmation']; $context = array( 'user' => $user, 'confirmationUrl' => $confirmationUrl, ); $this->sendMessage($template, $context, $fromEmail, $toEmail); }
[ "public", "function", "sendUpdateEmailConfirmation", "(", "UserInterface", "$", "user", ",", "$", "confirmationUrl", ",", "$", "toEmail", ")", "{", "$", "template", "=", "$", "this", "->", "parameters", "[", "'template'", "]", "[", "'email_updating'", "]", ";"...
Send confirmation link to specified new user email. @param UserInterface $user @param $confirmationUrl @param $toEmail @return bool
[ "Send", "confirmation", "link", "to", "specified", "new", "user", "email", "." ]
e1d25da6600a5a068709074cb4d7ece15ceaaae6
https://github.com/azine/email-bundle/blob/e1d25da6600a5a068709074cb4d7ece15ceaaae6/Services/AzineTwigSwiftMailer.php#L535-L545
train
laravel-notification-channels/gcm
src/Packet.php
Packet.toJson
public function toJson() { $json = []; if (! empty($this->registrationIds)) { $json['registration_ids'] = $this->registrationIds; } if ($this->collapseKey) { $json['collapse_key'] = $this->collapseKey; } if (! empty($this->data)) { $json['data'] = $this->data; } if (! empty($this->notification)) { $json['notification'] = $this->notification; } if ($this->delayWhileIdle) { $json['delay_while_idle'] = $this->delayWhileIdle; } if ($this->timeToLive != 2419200) { $json['time_to_live'] = $this->timeToLive; } if ($this->restrictedPackageName) { $json['restricted_package_name'] = $this->restrictedPackageName; } if ($this->dryRun) { $json['dry_run'] = $this->dryRun; } return Json::encode($json); }
php
public function toJson() { $json = []; if (! empty($this->registrationIds)) { $json['registration_ids'] = $this->registrationIds; } if ($this->collapseKey) { $json['collapse_key'] = $this->collapseKey; } if (! empty($this->data)) { $json['data'] = $this->data; } if (! empty($this->notification)) { $json['notification'] = $this->notification; } if ($this->delayWhileIdle) { $json['delay_while_idle'] = $this->delayWhileIdle; } if ($this->timeToLive != 2419200) { $json['time_to_live'] = $this->timeToLive; } if ($this->restrictedPackageName) { $json['restricted_package_name'] = $this->restrictedPackageName; } if ($this->dryRun) { $json['dry_run'] = $this->dryRun; } return Json::encode($json); }
[ "public", "function", "toJson", "(", ")", "{", "$", "json", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "registrationIds", ")", ")", "{", "$", "json", "[", "'registration_ids'", "]", "=", "$", "this", "->", "registrationIds",...
To JSON Utility method to put the JSON into the GCM proper format for sending the message. @return string
[ "To", "JSON", "Utility", "method", "to", "put", "the", "JSON", "into", "the", "GCM", "proper", "format", "for", "sending", "the", "message", "." ]
f2b20d6b4232eaccb674571ef90223bf402f086b
https://github.com/laravel-notification-channels/gcm/blob/f2b20d6b4232eaccb674571ef90223bf402f086b/src/Packet.php#L35-L72
train
laravel-notification-channels/gcm
src/GcmChannel.php
GcmChannel.send
public function send($notifiable, Notification $notification) { $tokens = (array) $notifiable->routeNotificationFor('gcm', $notification); if (empty($tokens)) { return; } $message = $notification->toGcm($notifiable); if (! $message) { return; } $packet = $this->getPacket($tokens, $message); try { $response = $this->client->send($packet); } catch (Exception $exception) { throw SendingFailed::create($exception); } if (! $response->getFailureCount() == 0) { $this->handleFailedNotifications($notifiable, $notification, $response); } }
php
public function send($notifiable, Notification $notification) { $tokens = (array) $notifiable->routeNotificationFor('gcm', $notification); if (empty($tokens)) { return; } $message = $notification->toGcm($notifiable); if (! $message) { return; } $packet = $this->getPacket($tokens, $message); try { $response = $this->client->send($packet); } catch (Exception $exception) { throw SendingFailed::create($exception); } if (! $response->getFailureCount() == 0) { $this->handleFailedNotifications($notifiable, $notification, $response); } }
[ "public", "function", "send", "(", "$", "notifiable", ",", "Notification", "$", "notification", ")", "{", "$", "tokens", "=", "(", "array", ")", "$", "notifiable", "->", "routeNotificationFor", "(", "'gcm'", ",", "$", "notification", ")", ";", "if", "(", ...
Send the notification to Google Cloud Messaging. @param mixed $notifiable @param Notification $notification @return void @throws Exceptions\SendingFailed
[ "Send", "the", "notification", "to", "Google", "Cloud", "Messaging", "." ]
f2b20d6b4232eaccb674571ef90223bf402f086b
https://github.com/laravel-notification-channels/gcm/blob/f2b20d6b4232eaccb674571ef90223bf402f086b/src/GcmChannel.php#L48-L71
train
laravel-notification-channels/gcm
src/GcmChannel.php
GcmChannel.handleFailedNotifications
protected function handleFailedNotifications($notifiable, Notification $notification, $response) { $results = $response->getResults(); foreach ($results as $token => $result) { if (! isset($result['error'])) { continue; } $this->events->dispatch( new NotificationFailed($notifiable, $notification, get_class($this), [ 'token' => $token, 'error' => $result['error'], ]) ); } }
php
protected function handleFailedNotifications($notifiable, Notification $notification, $response) { $results = $response->getResults(); foreach ($results as $token => $result) { if (! isset($result['error'])) { continue; } $this->events->dispatch( new NotificationFailed($notifiable, $notification, get_class($this), [ 'token' => $token, 'error' => $result['error'], ]) ); } }
[ "protected", "function", "handleFailedNotifications", "(", "$", "notifiable", ",", "Notification", "$", "notification", ",", "$", "response", ")", "{", "$", "results", "=", "$", "response", "->", "getResults", "(", ")", ";", "foreach", "(", "$", "results", "...
Handle a failed notification. @param mixed $notifiable @param \Illuminate\Notifications\Notification $notification @param $response
[ "Handle", "a", "failed", "notification", "." ]
f2b20d6b4232eaccb674571ef90223bf402f086b
https://github.com/laravel-notification-channels/gcm/blob/f2b20d6b4232eaccb674571ef90223bf402f086b/src/GcmChannel.php#L104-L120
train
gerbenjacobs/HabboAPI
src/Entities/Habbo.php
Habbo.parse
public function parse($data) { // These attributes are shared between Habbo and Friends $this->setId($data['uniqueId']); $this->setHabboName($data['name']); $this->setMotto($data['motto']); if (isset($data['figureString'])) { $this->setFigureString($data['figureString']); } elseif (isset($data['habboFigure'])) { $this->setFigureString($data['habboFigure']); } // These could be missing.. if (isset($data['memberSince'])) { $this->setMemberSince($data['memberSince']); } if (isset($data['profileVisible'])) { $this->setProfileVisible($data['profileVisible']); } if (isset($data['selectedBadges'])) { foreach ($data['selectedBadges'] as $badge) { $selectedBadge = new Badge(); $selectedBadge->parse($badge); $this->addSelectedBadge($selectedBadge); } } }
php
public function parse($data) { // These attributes are shared between Habbo and Friends $this->setId($data['uniqueId']); $this->setHabboName($data['name']); $this->setMotto($data['motto']); if (isset($data['figureString'])) { $this->setFigureString($data['figureString']); } elseif (isset($data['habboFigure'])) { $this->setFigureString($data['habboFigure']); } // These could be missing.. if (isset($data['memberSince'])) { $this->setMemberSince($data['memberSince']); } if (isset($data['profileVisible'])) { $this->setProfileVisible($data['profileVisible']); } if (isset($data['selectedBadges'])) { foreach ($data['selectedBadges'] as $badge) { $selectedBadge = new Badge(); $selectedBadge->parse($badge); $this->addSelectedBadge($selectedBadge); } } }
[ "public", "function", "parse", "(", "$", "data", ")", "{", "// These attributes are shared between Habbo and Friends", "$", "this", "->", "setId", "(", "$", "data", "[", "'uniqueId'", "]", ")", ";", "$", "this", "->", "setHabboName", "(", "$", "data", "[", "...
Parses habbo info array to \Entities\Habbo object @param array $data
[ "Parses", "habbo", "info", "array", "to", "\\", "Entities", "\\", "Habbo", "object" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/Entities/Habbo.php#L31-L59
train
gerbenjacobs/HabboAPI
src/Entities/Room.php
Room.parse
public function parse($room) { $this->setId($room['id']); $this->setUniqueId($room['uniqueId']); $this->setName($room['name']); $this->setDescription($room['description']); $this->setMaximumVisitors($room['maximumVisitors']); $this->setTags($room['tags']); $this->setShowOwnerName($room['showOwnerName']); $this->setOwnerName($room['ownerName']); $this->setOwnerUniqueId($room['ownerUniqueId']); $this->setCategories($room['categories']); $this->setThumbnailUrl($room['thumbnailUrl']); $this->setImageUrl($room['imageUrl']); $this->setRating($room['rating']); if (isset($room['creationTime'])) { $this->setCreationTime($room['creationTime']); } if (isset($room['habboGroupId'])) { $this->setGroupId($room['habboGroupId']); } }
php
public function parse($room) { $this->setId($room['id']); $this->setUniqueId($room['uniqueId']); $this->setName($room['name']); $this->setDescription($room['description']); $this->setMaximumVisitors($room['maximumVisitors']); $this->setTags($room['tags']); $this->setShowOwnerName($room['showOwnerName']); $this->setOwnerName($room['ownerName']); $this->setOwnerUniqueId($room['ownerUniqueId']); $this->setCategories($room['categories']); $this->setThumbnailUrl($room['thumbnailUrl']); $this->setImageUrl($room['imageUrl']); $this->setRating($room['rating']); if (isset($room['creationTime'])) { $this->setCreationTime($room['creationTime']); } if (isset($room['habboGroupId'])) { $this->setGroupId($room['habboGroupId']); } }
[ "public", "function", "parse", "(", "$", "room", ")", "{", "$", "this", "->", "setId", "(", "$", "room", "[", "'id'", "]", ")", ";", "$", "this", "->", "setUniqueId", "(", "$", "room", "[", "'uniqueId'", "]", ")", ";", "$", "this", "->", "setName...
Parses room info array to \Entities\Room object @param array $room
[ "Parses", "room", "info", "array", "to", "\\", "Entities", "\\", "Room", "object" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/Entities/Room.php#L38-L61
train
gerbenjacobs/HabboAPI
src/HabboParser.php
HabboParser.parseHabbo
public function parseHabbo($identifier, $useUniqueId = false) { if ($useUniqueId) { $url = '/api/public/users/' . $identifier; } else { $url = '/api/public/users?name=' . $identifier; } list($data) = $this->_callUrl($this->api_base . $url, true); $habbo = new Habbo(); $habbo->parse($data); return $habbo; }
php
public function parseHabbo($identifier, $useUniqueId = false) { if ($useUniqueId) { $url = '/api/public/users/' . $identifier; } else { $url = '/api/public/users?name=' . $identifier; } list($data) = $this->_callUrl($this->api_base . $url, true); $habbo = new Habbo(); $habbo->parse($data); return $habbo; }
[ "public", "function", "parseHabbo", "(", "$", "identifier", ",", "$", "useUniqueId", "=", "false", ")", "{", "if", "(", "$", "useUniqueId", ")", "{", "$", "url", "=", "'/api/public/users/'", ".", "$", "identifier", ";", "}", "else", "{", "$", "url", "=...
Parses the Habbo user endpoint @param $identifier @param bool $useUniqueId @return Habbo @throws Exception
[ "Parses", "the", "Habbo", "user", "endpoint" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/HabboParser.php#L57-L70
train
gerbenjacobs/HabboAPI
src/HabboParser.php
HabboParser.parseProfile
public function parseProfile($id) { // Collect JSON list($data) = $this->_callUrl($this->api_base . '/api/public/users/' . $id . '/profile', true); // Create Profile entity $profile = new Profile(); // Habbo $habbo = new Habbo(); $habbo->parse($data['user']); $profile->setHabbo($habbo); // Friends foreach ($data['friends'] as $friend) { $temp_friend = new Habbo(); $temp_friend->parse($friend); $profile->addFriend($temp_friend); } // Groups foreach ($data['groups'] as $group) { $temp_group = new Group(); $temp_group->parse($group); $profile->addGroup($temp_group); } // Rooms foreach ($data['rooms'] as $room) { $temp_room = new Room(); $temp_room->parse($room); $profile->addRoom($temp_room); } // Badges foreach ($data['badges'] as $badge) { $temp_badge = new Badge(); $temp_badge->parse($badge); $profile->addBadge($temp_badge); } // Return the Profile return $profile; }
php
public function parseProfile($id) { // Collect JSON list($data) = $this->_callUrl($this->api_base . '/api/public/users/' . $id . '/profile', true); // Create Profile entity $profile = new Profile(); // Habbo $habbo = new Habbo(); $habbo->parse($data['user']); $profile->setHabbo($habbo); // Friends foreach ($data['friends'] as $friend) { $temp_friend = new Habbo(); $temp_friend->parse($friend); $profile->addFriend($temp_friend); } // Groups foreach ($data['groups'] as $group) { $temp_group = new Group(); $temp_group->parse($group); $profile->addGroup($temp_group); } // Rooms foreach ($data['rooms'] as $room) { $temp_room = new Room(); $temp_room->parse($room); $profile->addRoom($temp_room); } // Badges foreach ($data['badges'] as $badge) { $temp_badge = new Badge(); $temp_badge->parse($badge); $profile->addBadge($temp_badge); } // Return the Profile return $profile; }
[ "public", "function", "parseProfile", "(", "$", "id", ")", "{", "// Collect JSON", "list", "(", "$", "data", ")", "=", "$", "this", "->", "_callUrl", "(", "$", "this", "->", "api_base", ".", "'/api/public/users/'", ".", "$", "id", ".", "'/profile'", ",",...
Parses the Habbo Profile endpoints Return a Profile object including a Habbo entity and 4 arrays with Group, Friend, Room, Badge entities @param string $id @return Profile @throws Exception
[ "Parses", "the", "Habbo", "Profile", "endpoints" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/HabboParser.php#L81-L124
train
gerbenjacobs/HabboAPI
src/HabboParser.php
HabboParser.parseGroup
public function parseGroup($group_id) { list($data) = $this->_callUrl($this->api_base . '/api/public/groups/' . $group_id, true); $group = new Group(); $group->parse($data); try { list($member_data) = $this->_callUrl($this->api_base . '/api/public/groups/' . $group_id . '/members', true); } catch (Exception $e) { // Can't collect member data $member_data = false; } if ($member_data) { /** @var Habbo[] $members */ $members = array(); foreach ($member_data as $member) { $temp_habbo = new Habbo(); $temp_habbo->parse($member); $members[] = $temp_habbo; } $group->setMembers($members); } return $group; }
php
public function parseGroup($group_id) { list($data) = $this->_callUrl($this->api_base . '/api/public/groups/' . $group_id, true); $group = new Group(); $group->parse($data); try { list($member_data) = $this->_callUrl($this->api_base . '/api/public/groups/' . $group_id . '/members', true); } catch (Exception $e) { // Can't collect member data $member_data = false; } if ($member_data) { /** @var Habbo[] $members */ $members = array(); foreach ($member_data as $member) { $temp_habbo = new Habbo(); $temp_habbo->parse($member); $members[] = $temp_habbo; } $group->setMembers($members); } return $group; }
[ "public", "function", "parseGroup", "(", "$", "group_id", ")", "{", "list", "(", "$", "data", ")", "=", "$", "this", "->", "_callUrl", "(", "$", "this", "->", "api_base", ".", "'/api/public/groups/'", ".", "$", "group_id", ",", "true", ")", ";", "$", ...
parseGroup will return a Group object based on a group ID. It will also contain the members, as an array of Habbo objects. @param $group_id @return Group @throws Exception
[ "parseGroup", "will", "return", "a", "Group", "object", "based", "on", "a", "group", "ID", ".", "It", "will", "also", "contain", "the", "members", "as", "an", "array", "of", "Habbo", "objects", "." ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/HabboParser.php#L161-L187
train
gerbenjacobs/HabboAPI
src/HabboParser.php
HabboParser.parseAchievements
public function parseAchievements($id) { $achievements = array(); list($data) = $this->_callUrl($this->api_base . '/api/public/achievements/' . $id, true); if ($data) { foreach ($data as $ach) { $tmp_ach = new Achievement(); $tmp_ach->parse($ach); $achievements[] = $tmp_ach; unset($tmp_ach); } } return $achievements; }
php
public function parseAchievements($id) { $achievements = array(); list($data) = $this->_callUrl($this->api_base . '/api/public/achievements/' . $id, true); if ($data) { foreach ($data as $ach) { $tmp_ach = new Achievement(); $tmp_ach->parse($ach); $achievements[] = $tmp_ach; unset($tmp_ach); } } return $achievements; }
[ "public", "function", "parseAchievements", "(", "$", "id", ")", "{", "$", "achievements", "=", "array", "(", ")", ";", "list", "(", "$", "data", ")", "=", "$", "this", "->", "_callUrl", "(", "$", "this", "->", "api_base", ".", "'/api/public/achievements/...
parseAchievements will return a list of achievements belonging to a Habbo @param $id @return Achievement[] @throws Exception
[ "parseAchievements", "will", "return", "a", "list", "of", "achievements", "belonging", "to", "a", "Habbo" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/HabboParser.php#L195-L211
train
gerbenjacobs/HabboAPI
src/HabboParser.php
HabboParser.throwHabboAPIException
public static function throwHabboAPIException($data) { // Do we find 'maintenance' anywhere? if (strstr($data, 'maintenance')) { throw new MaintenanceException("Hotel API is down for maintenance"); } // Check if data is JSON if ($data[0] == "{") { // Quick 'hack' to see if this could be JSON $json = json_decode($data, true); if (isset($json['errors'])) { if ($json['errors'][0]['msg'] == "user.invalid_name") { throw new UserInvalidException("The name you supplied appears to be invalid"); } $defaultMessage = $json['errors'][0]['msg']; } else if (isset($json['error'])) { if (preg_match('#not-found#', $json['error'])) { throw new HabboNotFoundException("We can not find the Habbo you're looking for"); } $defaultMessage = $json['error']; } else { $defaultMessage = $json; } } else { $defaultMessage = "An unknown HTML page was returned"; } throw new Exception("Unknown HabboAPI exception occurred: " . $defaultMessage); }
php
public static function throwHabboAPIException($data) { // Do we find 'maintenance' anywhere? if (strstr($data, 'maintenance')) { throw new MaintenanceException("Hotel API is down for maintenance"); } // Check if data is JSON if ($data[0] == "{") { // Quick 'hack' to see if this could be JSON $json = json_decode($data, true); if (isset($json['errors'])) { if ($json['errors'][0]['msg'] == "user.invalid_name") { throw new UserInvalidException("The name you supplied appears to be invalid"); } $defaultMessage = $json['errors'][0]['msg']; } else if (isset($json['error'])) { if (preg_match('#not-found#', $json['error'])) { throw new HabboNotFoundException("We can not find the Habbo you're looking for"); } $defaultMessage = $json['error']; } else { $defaultMessage = $json; } } else { $defaultMessage = "An unknown HTML page was returned"; } throw new Exception("Unknown HabboAPI exception occurred: " . $defaultMessage); }
[ "public", "static", "function", "throwHabboAPIException", "(", "$", "data", ")", "{", "// Do we find 'maintenance' anywhere?", "if", "(", "strstr", "(", "$", "data", ",", "'maintenance'", ")", ")", "{", "throw", "new", "MaintenanceException", "(", "\"Hotel API is do...
deciphers data returned from Habbo and tries to throw the correct exception @param $data @throws Exception @throws HabboNotFoundException @throws MaintenanceException @throws UserInvalidException
[ "deciphers", "data", "returned", "from", "Habbo", "and", "tries", "to", "throw", "the", "correct", "exception" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/HabboParser.php#L254-L282
train
gerbenjacobs/HabboAPI
src/Entities/Group.php
Group.parse
public function parse($group) { $this->setId($group['id']); $this->setName($group['name']); $this->setDescription($group['description']); $this->setType($group['type']); if (isset($group['primaryColour'])) { $this->setPrimaryColour($group['primaryColour']); } if (isset($group['secondaryColour'])) { $this->setSecondaryColour($group['secondaryColour']); } if (isset($group['badgeCode'])) { $this->setBadgeCode($group['badgeCode']); } if (isset($group['roomId'])) { $this->setRoomId($group['roomId']); } if (isset($group['isAdmin'])) { $this->setIsAdmin($group['isAdmin']); } }
php
public function parse($group) { $this->setId($group['id']); $this->setName($group['name']); $this->setDescription($group['description']); $this->setType($group['type']); if (isset($group['primaryColour'])) { $this->setPrimaryColour($group['primaryColour']); } if (isset($group['secondaryColour'])) { $this->setSecondaryColour($group['secondaryColour']); } if (isset($group['badgeCode'])) { $this->setBadgeCode($group['badgeCode']); } if (isset($group['roomId'])) { $this->setRoomId($group['roomId']); } if (isset($group['isAdmin'])) { $this->setIsAdmin($group['isAdmin']); } }
[ "public", "function", "parse", "(", "$", "group", ")", "{", "$", "this", "->", "setId", "(", "$", "group", "[", "'id'", "]", ")", ";", "$", "this", "->", "setName", "(", "$", "group", "[", "'name'", "]", ")", ";", "$", "this", "->", "setDescripti...
Parses group info array to \Entities\Group object @param array $group
[ "Parses", "group", "info", "array", "to", "\\", "Entities", "\\", "Group", "object" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/Entities/Group.php#L21-L42
train
gerbenjacobs/HabboAPI
src/Entities/Badge.php
Badge.parse
public function parse($badge) { if (isset($badge['badgeIndex'])) { $this->setBadgeIndex($badge['badgeIndex']); } $this->setCode($badge['code']); $this->setName($badge['name']); $this->setDescription($badge['description']); }
php
public function parse($badge) { if (isset($badge['badgeIndex'])) { $this->setBadgeIndex($badge['badgeIndex']); } $this->setCode($badge['code']); $this->setName($badge['name']); $this->setDescription($badge['description']); }
[ "public", "function", "parse", "(", "$", "badge", ")", "{", "if", "(", "isset", "(", "$", "badge", "[", "'badgeIndex'", "]", ")", ")", "{", "$", "this", "->", "setBadgeIndex", "(", "$", "badge", "[", "'badgeIndex'", "]", ")", ";", "}", "$", "this",...
Parses badge info array to Badge object @param array $badge
[ "Parses", "badge", "info", "array", "to", "Badge", "object" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/Entities/Badge.php#L23-L31
train
gerbenjacobs/HabboAPI
src/Entities/Profile.php
Profile.getCounts
public function getCounts() { return array( 'habbo' => count($this->habbo), 'badges' => count($this->badges), 'friends' => count($this->friends), 'groups' => count($this->groups), 'rooms' => count($this->rooms), ); }
php
public function getCounts() { return array( 'habbo' => count($this->habbo), 'badges' => count($this->badges), 'friends' => count($this->friends), 'groups' => count($this->groups), 'rooms' => count($this->rooms), ); }
[ "public", "function", "getCounts", "(", ")", "{", "return", "array", "(", "'habbo'", "=>", "count", "(", "$", "this", "->", "habbo", ")", ",", "'badges'", "=>", "count", "(", "$", "this", "->", "badges", ")", ",", "'friends'", "=>", "count", "(", "$"...
getCounts is a small helper function to give you an array of each entity in the profile and its count @return array
[ "getCounts", "is", "a", "small", "helper", "function", "to", "give", "you", "an", "array", "of", "each", "entity", "in", "the", "profile", "and", "its", "count" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/Entities/Profile.php#L133-L142
train
gerbenjacobs/HabboAPI
src/Entities/Achievement.php
Achievement.parse
public function parse($achievement) { // add default fields $this->id = $achievement['achievement']['id']; $this->name = $achievement['achievement']['name']; $this->category = $achievement['achievement']['category']; // add requirements if available if (isset($achievement['requirements'])) { $this->requirements = $achievement['requirements']; } // add user state if available if (isset($achievement['level'])) { $this->level = $achievement['level']; } if (isset($achievement['score'])) { $this->score = $achievement['score']; } }
php
public function parse($achievement) { // add default fields $this->id = $achievement['achievement']['id']; $this->name = $achievement['achievement']['name']; $this->category = $achievement['achievement']['category']; // add requirements if available if (isset($achievement['requirements'])) { $this->requirements = $achievement['requirements']; } // add user state if available if (isset($achievement['level'])) { $this->level = $achievement['level']; } if (isset($achievement['score'])) { $this->score = $achievement['score']; } }
[ "public", "function", "parse", "(", "$", "achievement", ")", "{", "// add default fields", "$", "this", "->", "id", "=", "$", "achievement", "[", "'achievement'", "]", "[", "'id'", "]", ";", "$", "this", "->", "name", "=", "$", "achievement", "[", "'achi...
Parses achievement info array to Achievement object @param $achievement
[ "Parses", "achievement", "info", "array", "to", "Achievement", "object" ]
f7d81d50194ff0618dfeb3b72db9a8b90f6613b3
https://github.com/gerbenjacobs/HabboAPI/blob/f7d81d50194ff0618dfeb3b72db9a8b90f6613b3/src/Entities/Achievement.php#L22-L41
train
delight-im/PHP-Str
src/Str.php
Str.fromArray
public static function fromArray($rawArray, $charset = null) { $output = array(); foreach ($rawArray as $rawEntry) { $output[] = new static($rawEntry, $charset); } return $output; }
php
public static function fromArray($rawArray, $charset = null) { $output = array(); foreach ($rawArray as $rawEntry) { $output[] = new static($rawEntry, $charset); } return $output; }
[ "public", "static", "function", "fromArray", "(", "$", "rawArray", ",", "$", "charset", "=", "null", ")", "{", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "rawArray", "as", "$", "rawEntry", ")", "{", "$", "output", "[", "]", "=...
Variant of the static "constructor" that operates on arrays @param string[] $rawArray the array of strings to create instances from @param string|null $charset the charset to use (one of the values listed by `mb_list_encodings`) (optional) @return static[] the new instances of this class
[ "Variant", "of", "the", "static", "constructor", "that", "operates", "on", "arrays" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L51-L59
train
delight-im/PHP-Str
src/Str.php
Str.first
public function first($length = null) { if ($length === null) { $length = 1; } $rawString = mb_substr($this->rawString, 0, $length, $this->charset); return new static($rawString, $this->charset); }
php
public function first($length = null) { if ($length === null) { $length = 1; } $rawString = mb_substr($this->rawString, 0, $length, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "first", "(", "$", "length", "=", "null", ")", "{", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", "1", ";", "}", "$", "rawString", "=", "mb_substr", "(", "$", "this", "->", "rawString", ",", "0", ","...
Returns the first character or the specified number of characters from the start of this string @param int|null $length the number of characters to return from the start (optional) @return static a new instance of this class
[ "Returns", "the", "first", "character", "or", "the", "specified", "number", "of", "characters", "from", "the", "start", "of", "this", "string" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L187-L195
train
delight-im/PHP-Str
src/Str.php
Str.last
public function last($length = null) { if ($length === null) { $length = 1; } $offset = $this->length() - $length; $rawString = mb_substr($this->rawString, $offset, null, $this->charset); return new static($rawString, $this->charset); }
php
public function last($length = null) { if ($length === null) { $length = 1; } $offset = $this->length() - $length; $rawString = mb_substr($this->rawString, $offset, null, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "last", "(", "$", "length", "=", "null", ")", "{", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", "1", ";", "}", "$", "offset", "=", "$", "this", "->", "length", "(", ")", "-", "$", "length", ";", ...
Returns the last character or the specified number of characters from the end of this string @param int|null $length the number of characters to return from the end (optional) @return static a new instance of this class
[ "Returns", "the", "last", "character", "or", "the", "specified", "number", "of", "characters", "from", "the", "end", "of", "this", "string" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L214-L224
train
delight-im/PHP-Str
src/Str.php
Str.toLowerCase
public function toLowerCase() { $rawString = mb_strtolower($this->rawString, $this->charset); return new static($rawString, $this->charset); }
php
public function toLowerCase() { $rawString = mb_strtolower($this->rawString, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "toLowerCase", "(", ")", "{", "$", "rawString", "=", "mb_strtolower", "(", "$", "this", "->", "rawString", ",", "$", "this", "->", "charset", ")", ";", "return", "new", "static", "(", "$", "rawString", ",", "$", "this", "->", "cha...
Converts this string to lowercase @return static a new instance of this class
[ "Converts", "this", "string", "to", "lowercase" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L231-L235
train
delight-im/PHP-Str
src/Str.php
Str.toUpperCase
public function toUpperCase() { $rawString = mb_strtoupper($this->rawString, $this->charset); return new static($rawString, $this->charset); }
php
public function toUpperCase() { $rawString = mb_strtoupper($this->rawString, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "toUpperCase", "(", ")", "{", "$", "rawString", "=", "mb_strtoupper", "(", "$", "this", "->", "rawString", ",", "$", "this", "->", "charset", ")", ";", "return", "new", "static", "(", "$", "rawString", ",", "$", "this", "->", "cha...
Converts this string to uppercase @return static a new instance of this class
[ "Converts", "this", "string", "to", "uppercase" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L251-L255
train
delight-im/PHP-Str
src/Str.php
Str.count
public function count($substring = null) { if ($substring === null) { return mb_strlen($this->rawString, $this->charset); } else { return mb_substr_count($this->rawString, $substring, $this->charset); } }
php
public function count($substring = null) { if ($substring === null) { return mb_strlen($this->rawString, $this->charset); } else { return mb_substr_count($this->rawString, $substring, $this->charset); } }
[ "public", "function", "count", "(", "$", "substring", "=", "null", ")", "{", "if", "(", "$", "substring", "===", "null", ")", "{", "return", "mb_strlen", "(", "$", "this", "->", "rawString", ",", "$", "this", "->", "charset", ")", ";", "}", "else", ...
Counts the occurrences of the specified substring in this string @param string $substring the substring whose occurrences to count @return int the number of occurrences
[ "Counts", "the", "occurrences", "of", "the", "specified", "substring", "in", "this", "string" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L305-L312
train
delight-im/PHP-Str
src/Str.php
Str.cutStart
public function cutStart($length) { $rawString = mb_substr($this->rawString, $length, null, $this->charset); return new static($rawString, $this->charset); }
php
public function cutStart($length) { $rawString = mb_substr($this->rawString, $length, null, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "cutStart", "(", "$", "length", ")", "{", "$", "rawString", "=", "mb_substr", "(", "$", "this", "->", "rawString", ",", "$", "length", ",", "null", ",", "$", "this", "->", "charset", ")", ";", "return", "new", "static", "(", "$"...
Removes the specified number of characters from the start of this string @param int $length the number of characters to remove @return static a new instance of this class
[ "Removes", "the", "specified", "number", "of", "characters", "from", "the", "start", "of", "this", "string" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L329-L333
train
delight-im/PHP-Str
src/Str.php
Str.cutEnd
public function cutEnd($length) { $rawString = mb_substr($this->rawString, 0, $this->length() - $length, $this->charset); return new static($rawString, $this->charset); }
php
public function cutEnd($length) { $rawString = mb_substr($this->rawString, 0, $this->length() - $length, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "cutEnd", "(", "$", "length", ")", "{", "$", "rawString", "=", "mb_substr", "(", "$", "this", "->", "rawString", ",", "0", ",", "$", "this", "->", "length", "(", ")", "-", "$", "length", ",", "$", "this", "->", "charset", ")",...
Removes the specified number of characters from the end of this string @param int $length the number of characters to remove @return static a new instance of this class
[ "Removes", "the", "specified", "number", "of", "characters", "from", "the", "end", "of", "this", "string" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L341-L345
train
delight-im/PHP-Str
src/Str.php
Str.replacePrefix
public function replacePrefix($searchFor, $replaceWith = null) { if ($this->startsWith($searchFor)) { return $this->replaceFirst($searchFor, $replaceWith); } else { return $this; } }
php
public function replacePrefix($searchFor, $replaceWith = null) { if ($this->startsWith($searchFor)) { return $this->replaceFirst($searchFor, $replaceWith); } else { return $this; } }
[ "public", "function", "replacePrefix", "(", "$", "searchFor", ",", "$", "replaceWith", "=", "null", ")", "{", "if", "(", "$", "this", "->", "startsWith", "(", "$", "searchFor", ")", ")", "{", "return", "$", "this", "->", "replaceFirst", "(", "$", "sear...
Replaces the specified part in this string only if it starts with that part @param string $searchFor the string to search for @param string $replaceWith the string to use as the replacement (optional) @return static a new instance of this class
[ "Replaces", "the", "specified", "part", "in", "this", "string", "only", "if", "it", "starts", "with", "that", "part" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L402-L409
train
delight-im/PHP-Str
src/Str.php
Str.replaceSuffix
public function replaceSuffix($searchFor, $replaceWith = null) { if ($this->endsWith($searchFor)) { return $this->replaceLast($searchFor, $replaceWith); } else { return $this; } }
php
public function replaceSuffix($searchFor, $replaceWith = null) { if ($this->endsWith($searchFor)) { return $this->replaceLast($searchFor, $replaceWith); } else { return $this; } }
[ "public", "function", "replaceSuffix", "(", "$", "searchFor", ",", "$", "replaceWith", "=", "null", ")", "{", "if", "(", "$", "this", "->", "endsWith", "(", "$", "searchFor", ")", ")", "{", "return", "$", "this", "->", "replaceLast", "(", "$", "searchF...
Replaces the specified part in this string only if it ends with that part @param string $searchFor the string to search for @param string $replaceWith the string to use as the replacement (optional) @return static a new instance of this class
[ "Replaces", "the", "specified", "part", "in", "this", "string", "only", "if", "it", "ends", "with", "that", "part" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L442-L449
train
delight-im/PHP-Str
src/Str.php
Str.split
public function split($delimiter, $limit = null) { if ($limit === null) { $limit = PHP_INT_MAX; } return self::fromArray(explode($delimiter, $this->rawString, $limit)); }
php
public function split($delimiter, $limit = null) { if ($limit === null) { $limit = PHP_INT_MAX; } return self::fromArray(explode($delimiter, $this->rawString, $limit)); }
[ "public", "function", "split", "(", "$", "delimiter", ",", "$", "limit", "=", "null", ")", "{", "if", "(", "$", "limit", "===", "null", ")", "{", "$", "limit", "=", "PHP_INT_MAX", ";", "}", "return", "self", "::", "fromArray", "(", "explode", "(", ...
Splits this string into an array of substrings at the specified delimiter @param string $delimiter the delimiter to split the string at @param int|null $limit the maximum number of substrings to return (optional) @return static[] the new instances of this class
[ "Splits", "this", "string", "into", "an", "array", "of", "substrings", "at", "the", "specified", "delimiter" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L458-L464
train
delight-im/PHP-Str
src/Str.php
Str.splitByRegex
public function splitByRegex($delimiterPattern, $limit = null, $flags = null) { if ($limit === null) { $limit = -1; } if ($flags === null) { $flags = 0; } return self::fromArray(preg_split($delimiterPattern, $this->rawString, $limit, $flags)); }
php
public function splitByRegex($delimiterPattern, $limit = null, $flags = null) { if ($limit === null) { $limit = -1; } if ($flags === null) { $flags = 0; } return self::fromArray(preg_split($delimiterPattern, $this->rawString, $limit, $flags)); }
[ "public", "function", "splitByRegex", "(", "$", "delimiterPattern", ",", "$", "limit", "=", "null", ",", "$", "flags", "=", "null", ")", "{", "if", "(", "$", "limit", "===", "null", ")", "{", "$", "limit", "=", "-", "1", ";", "}", "if", "(", "$",...
Splits this string into an array of substrings at the specified delimiter pattern @param string $delimiterPattern the regular expression (PCRE) to split the string at @param int|null $limit the maximum number of substrings to return (optional) @param int|null $flags any combination (bit-wise ORed) of PHP's `PREG_SPLIT_*` flags @return static[] the new instances of this class
[ "Splits", "this", "string", "into", "an", "array", "of", "substrings", "at", "the", "specified", "delimiter", "pattern" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L474-L484
train
delight-im/PHP-Str
src/Str.php
Str.words
public function words($limit = null) { // if a limit has been specified if ($limit !== null) { // get one entry more than requested $limit += 1; } // split the string into words $words = $this->splitByRegex('/[^\\w\']+/u', $limit, PREG_SPLIT_NO_EMPTY); // if a limit has been specified if ($limit !== null) { // discard the last entry (which contains the remainder of the string) array_pop($words); } // return the words return $words; }
php
public function words($limit = null) { // if a limit has been specified if ($limit !== null) { // get one entry more than requested $limit += 1; } // split the string into words $words = $this->splitByRegex('/[^\\w\']+/u', $limit, PREG_SPLIT_NO_EMPTY); // if a limit has been specified if ($limit !== null) { // discard the last entry (which contains the remainder of the string) array_pop($words); } // return the words return $words; }
[ "public", "function", "words", "(", "$", "limit", "=", "null", ")", "{", "// if a limit has been specified", "if", "(", "$", "limit", "!==", "null", ")", "{", "// get one entry more than requested", "$", "limit", "+=", "1", ";", "}", "// split the string into word...
Splits this string into its single words @param int|null the maximum number of words to return from the start (optional) @return static[] the new instances of this class
[ "Splits", "this", "string", "into", "its", "single", "words" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L492-L510
train
delight-im/PHP-Str
src/Str.php
Str.between
public function between($start, $end) { $beforeStart = mb_strpos($this->rawString, $start, 0, $this->charset); $rawString = ''; if ($beforeStart !== false) { $afterStart = $beforeStart + mb_strlen($start, $this->charset); $beforeEnd = mb_strrpos($this->rawString, $end, $afterStart, $this->charset); if ($beforeEnd !== false) { $rawString = mb_substr($this->rawString, $afterStart, $beforeEnd - $afterStart, $this->charset); } } return new static($rawString, $this->charset); }
php
public function between($start, $end) { $beforeStart = mb_strpos($this->rawString, $start, 0, $this->charset); $rawString = ''; if ($beforeStart !== false) { $afterStart = $beforeStart + mb_strlen($start, $this->charset); $beforeEnd = mb_strrpos($this->rawString, $end, $afterStart, $this->charset); if ($beforeEnd !== false) { $rawString = mb_substr($this->rawString, $afterStart, $beforeEnd - $afterStart, $this->charset); } } return new static($rawString, $this->charset); }
[ "public", "function", "between", "(", "$", "start", ",", "$", "end", ")", "{", "$", "beforeStart", "=", "mb_strpos", "(", "$", "this", "->", "rawString", ",", "$", "start", ",", "0", ",", "$", "this", "->", "charset", ")", ";", "$", "rawString", "=...
Returns the part of this string between the two specified substrings If there are multiple occurrences, the part with the maximum length will be returned @param string $start the substring whose first occurrence should delimit the start @param string $end the substring whose last occurrence should delimit the end @return static a new instance of this class
[ "Returns", "the", "part", "of", "this", "string", "between", "the", "two", "specified", "substrings" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L541-L556
train
delight-im/PHP-Str
src/Str.php
Str.escapeForHtml
public function escapeForHtml() { $rawString = htmlspecialchars($this->rawString, ENT_QUOTES, $this->charset); return new static($rawString, $this->charset); }
php
public function escapeForHtml() { $rawString = htmlspecialchars($this->rawString, ENT_QUOTES, $this->charset); return new static($rawString, $this->charset); }
[ "public", "function", "escapeForHtml", "(", ")", "{", "$", "rawString", "=", "htmlspecialchars", "(", "$", "this", "->", "rawString", ",", "ENT_QUOTES", ",", "$", "this", "->", "charset", ")", ";", "return", "new", "static", "(", "$", "rawString", ",", "...
Escapes this string for safe use in HTML @return static a new instance of this class
[ "Escapes", "this", "string", "for", "safe", "use", "in", "HTML" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L657-L661
train
delight-im/PHP-Str
src/Str.php
Str.reverse
public function reverse() { if (preg_match_all('/./us', $this->rawString, $matches)) { $rawString = join('', array_reverse($matches[0])); return new static($rawString, $this->charset); } else { return $this; } }
php
public function reverse() { if (preg_match_all('/./us', $this->rawString, $matches)) { $rawString = join('', array_reverse($matches[0])); return new static($rawString, $this->charset); } else { return $this; } }
[ "public", "function", "reverse", "(", ")", "{", "if", "(", "preg_match_all", "(", "'/./us'", ",", "$", "this", "->", "rawString", ",", "$", "matches", ")", ")", "{", "$", "rawString", "=", "join", "(", "''", ",", "array_reverse", "(", "$", "matches", ...
Reverses this string @return static a new instance of this class
[ "Reverses", "this", "string" ]
606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9
https://github.com/delight-im/PHP-Str/blob/606e36c9c5297eb01ad04b8a57e3dcbdfb0d98a9/src/Str.php#L684-L693
train
thephpleague/tactician-doctrine
src/ORM/TransactionMiddleware.php
TransactionMiddleware.rollbackTransaction
protected function rollbackTransaction() { $this->entityManager->rollback(); $connection = $this->entityManager->getConnection(); if (!$connection->isTransactionActive() || $connection->isRollbackOnly()) { $this->entityManager->close(); } }
php
protected function rollbackTransaction() { $this->entityManager->rollback(); $connection = $this->entityManager->getConnection(); if (!$connection->isTransactionActive() || $connection->isRollbackOnly()) { $this->entityManager->close(); } }
[ "protected", "function", "rollbackTransaction", "(", ")", "{", "$", "this", "->", "entityManager", "->", "rollback", "(", ")", ";", "$", "connection", "=", "$", "this", "->", "entityManager", "->", "getConnection", "(", ")", ";", "if", "(", "!", "$", "co...
Rollback the current transaction and close the entity manager when possible.
[ "Rollback", "the", "current", "transaction", "and", "close", "the", "entity", "manager", "when", "possible", "." ]
c318a16c0f0461bc3a277753788af5b930d6359e
https://github.com/thephpleague/tactician-doctrine/blob/c318a16c0f0461bc3a277753788af5b930d6359e/src/ORM/TransactionMiddleware.php#L61-L69
train
delight-im/PHP-FileUpload
src/DataUriUpload.php
DataUriUpload.getAllowedMimeTypesAsHumanString
public function getAllowedMimeTypesAsHumanString($lastSeparator = null) { $separator = ', '; $str = \implode($separator, $this->getAllowedMimeTypesAsArray()); if ($lastSeparator !== null) { $lastSeparatorPosition = \strrpos($str, $separator); if ($lastSeparatorPosition !== false) { $str = \substr_replace($str, $lastSeparator, $lastSeparatorPosition, \strlen($separator)); } } return $str; }
php
public function getAllowedMimeTypesAsHumanString($lastSeparator = null) { $separator = ', '; $str = \implode($separator, $this->getAllowedMimeTypesAsArray()); if ($lastSeparator !== null) { $lastSeparatorPosition = \strrpos($str, $separator); if ($lastSeparatorPosition !== false) { $str = \substr_replace($str, $lastSeparator, $lastSeparatorPosition, \strlen($separator)); } } return $str; }
[ "public", "function", "getAllowedMimeTypesAsHumanString", "(", "$", "lastSeparator", "=", "null", ")", "{", "$", "separator", "=", "', '", ";", "$", "str", "=", "\\", "implode", "(", "$", "separator", ",", "$", "this", "->", "getAllowedMimeTypesAsArray", "(", ...
Returns the list of permitted MIME types as a human-readable string @param string|null $lastSeparator (optional) the last separator as an alternative to the comma, e.g. ` or ` @return string
[ "Returns", "the", "list", "of", "permitted", "MIME", "types", "as", "a", "human", "-", "readable", "string" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/DataUriUpload.php#L130-L144
train
delight-im/PHP-FileUpload
src/Directory.php
Directory.deleteRecursively
public function deleteRecursively() { if ($this->exists()) { $entries = @\scandir($this->path); foreach ($entries as $entry) { if ($entry !== '.' && $entry !== '..') { $entryPath = $this->path . '/' . $entry; if (@\is_dir($entryPath)) { $this->deleteRecursively($entryPath); } else { @\unlink($entryPath); } } } @\rmdir($this->path); } }
php
public function deleteRecursively() { if ($this->exists()) { $entries = @\scandir($this->path); foreach ($entries as $entry) { if ($entry !== '.' && $entry !== '..') { $entryPath = $this->path . '/' . $entry; if (@\is_dir($entryPath)) { $this->deleteRecursively($entryPath); } else { @\unlink($entryPath); } } } @\rmdir($this->path); } }
[ "public", "function", "deleteRecursively", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "entries", "=", "@", "\\", "scandir", "(", "$", "this", "->", "path", ")", ";", "foreach", "(", "$", "entries", "as", "$", ...
Attempts to delete the directory including any contents recursively
[ "Attempts", "to", "delete", "the", "directory", "including", "any", "contents", "recursively" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/Directory.php#L87-L106
train
delight-im/PHP-FileUpload
src/Directory.php
Directory.createInternal
private function createInternal($recursive, $mode = null) { if ($mode === null) { $mode = 0755; } return @mkdir($this->path, $mode, $recursive); }
php
private function createInternal($recursive, $mode = null) { if ($mode === null) { $mode = 0755; } return @mkdir($this->path, $mode, $recursive); }
[ "private", "function", "createInternal", "(", "$", "recursive", ",", "$", "mode", "=", "null", ")", "{", "if", "(", "$", "mode", "===", "null", ")", "{", "$", "mode", "=", "0755", ";", "}", "return", "@", "mkdir", "(", "$", "this", "->", "path", ...
Attempts to create the directory @param bool $recursive whether missing parent directories (if any) should be created recursively @param int|null $mode (optional) the file mode (permissions) as used with the `chmod` method @return bool whether the directory has successfully been created
[ "Attempts", "to", "create", "the", "directory" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/Directory.php#L119-L125
train
delight-im/PHP-FileUpload
src/File.php
File.getFilenameWithExtension
public function getFilenameWithExtension() { if ($this->extension === null) { return $this->filename; } else { return $this->filename . '.' . $this->extension; } }
php
public function getFilenameWithExtension() { if ($this->extension === null) { return $this->filename; } else { return $this->filename . '.' . $this->extension; } }
[ "public", "function", "getFilenameWithExtension", "(", ")", "{", "if", "(", "$", "this", "->", "extension", "===", "null", ")", "{", "return", "$", "this", "->", "filename", ";", "}", "else", "{", "return", "$", "this", "->", "filename", ".", "'.'", "....
Returns the name of the file including its extension @return string
[ "Returns", "the", "name", "of", "the", "file", "including", "its", "extension" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/File.php#L70-L77
train
delight-im/PHP-FileUpload
src/FileUpload.php
FileUpload.from
public function from($inputName) { $this->sourceInputName = (string) $inputName; // remove leading and trailing whitespace $this->sourceInputName = \trim($this->sourceInputName); return $this; }
php
public function from($inputName) { $this->sourceInputName = (string) $inputName; // remove leading and trailing whitespace $this->sourceInputName = \trim($this->sourceInputName); return $this; }
[ "public", "function", "from", "(", "$", "inputName", ")", "{", "$", "this", "->", "sourceInputName", "=", "(", "string", ")", "$", "inputName", ";", "// remove leading and trailing whitespace", "$", "this", "->", "sourceInputName", "=", "\\", "trim", "(", "$",...
Sets the name of the file input whose selected file is to be received and stored @param string $inputName usually the `name` attribute of the `<input type="file">` HTML element @return static this instance for chaining
[ "Sets", "the", "name", "of", "the", "file", "input", "whose", "selected", "file", "is", "to", "be", "received", "and", "stored" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/FileUpload.php#L138-L145
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.withMaximumSizeInBytes
public function withMaximumSizeInBytes($size) { $size = (int) $size; if ($size > $this->maxTotalSize) { throw new TotalSizeExceededError(); } $this->maxIndividualSize = $size; return $this; }
php
public function withMaximumSizeInBytes($size) { $size = (int) $size; if ($size > $this->maxTotalSize) { throw new TotalSizeExceededError(); } $this->maxIndividualSize = $size; return $this; }
[ "public", "function", "withMaximumSizeInBytes", "(", "$", "size", ")", "{", "$", "size", "=", "(", "int", ")", "$", "size", ";", "if", "(", "$", "size", ">", "$", "this", "->", "maxTotalSize", ")", "{", "throw", "new", "TotalSizeExceededError", "(", ")...
Restricts the maximum size of individual files to be uploaded to the specified size @param int $size the size in bytes @return static this instance for chaining @throws Error (do *not* catch)
[ "Restricts", "the", "maximum", "size", "of", "individual", "files", "to", "be", "uploaded", "to", "the", "specified", "size" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L55-L65
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.withTargetFilename
public function withTargetFilename($targetFilename) { $targetFilename = (string) $targetFilename; $targetFilename = \trim($targetFilename); $this->targetFilename = $targetFilename; return $this; }
php
public function withTargetFilename($targetFilename) { $targetFilename = (string) $targetFilename; $targetFilename = \trim($targetFilename); $this->targetFilename = $targetFilename; return $this; }
[ "public", "function", "withTargetFilename", "(", "$", "targetFilename", ")", "{", "$", "targetFilename", "=", "(", "string", ")", "$", "targetFilename", ";", "$", "targetFilename", "=", "\\", "trim", "(", "$", "targetFilename", ")", ";", "$", "this", "->", ...
Sets the target filename which uploaded files are to be stored with If you do not specify a filename explicitly, a new random filename will be generated automatically The filename should *not* include any file extension because the extension will be appended automatically @param string $targetFilename @return static this instance for chaining
[ "Sets", "the", "target", "filename", "which", "uploaded", "files", "are", "to", "be", "stored", "with" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L173-L180
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.describeTargetFile
protected function describeTargetFile($extension) { if ($this->targetDirectory === null) { throw new TargetDirectoryNotSpecifiedError(); } $targetFilename = isset($this->targetFilename) ? $this->targetFilename : self::createRandomString(); if (!File::mayNameBeValid($targetFilename)) { throw new InvalidFilenameException(); } if (!$this->targetDirectory->exists() && !$this->targetDirectory->createRecursively(0755)) { throw new TargetFileWriteError(); } return new File($this->targetDirectory, $targetFilename, $extension); }
php
protected function describeTargetFile($extension) { if ($this->targetDirectory === null) { throw new TargetDirectoryNotSpecifiedError(); } $targetFilename = isset($this->targetFilename) ? $this->targetFilename : self::createRandomString(); if (!File::mayNameBeValid($targetFilename)) { throw new InvalidFilenameException(); } if (!$this->targetDirectory->exists() && !$this->targetDirectory->createRecursively(0755)) { throw new TargetFileWriteError(); } return new File($this->targetDirectory, $targetFilename, $extension); }
[ "protected", "function", "describeTargetFile", "(", "$", "extension", ")", "{", "if", "(", "$", "this", "->", "targetDirectory", "===", "null", ")", "{", "throw", "new", "TargetDirectoryNotSpecifiedError", "(", ")", ";", "}", "$", "targetFilename", "=", "isset...
Returns a description of the target file @param string $extension the filename extension to use @return File the description of the targe file @throws InvalidFilenameException if the supplied filename has been invalid @throws Error (do *not* catch)
[ "Returns", "a", "description", "of", "the", "target", "file" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L212-L228
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.areFileUploadsEnabled
private static function areFileUploadsEnabled() { if (self::parseIniBoolean(\ini_get('file_uploads')) === false) { return false; } if (((int) \ini_get('max_file_uploads')) <= 0) { return false; } return true; }
php
private static function areFileUploadsEnabled() { if (self::parseIniBoolean(\ini_get('file_uploads')) === false) { return false; } if (((int) \ini_get('max_file_uploads')) <= 0) { return false; } return true; }
[ "private", "static", "function", "areFileUploadsEnabled", "(", ")", "{", "if", "(", "self", "::", "parseIniBoolean", "(", "\\", "ini_get", "(", "'file_uploads'", ")", ")", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "(", "(", "int",...
Returns whether file uploads are enabled as per PHP's configuration @return bool
[ "Returns", "whether", "file", "uploads", "are", "enabled", "as", "per", "PHP", "s", "configuration" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L235-L245
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.determineMaximumUploadSize
private static function determineMaximumUploadSize() { $postMaxSize = self::parseIniSize( \ini_get('post_max_size') ); if ($postMaxSize <= 0) { $postMaxSize = \PHP_INT_MAX; } $memoryLimit = self::parseIniSize( \ini_get('memory_limit') ); if ($memoryLimit === -1) { $memoryLimit = \PHP_INT_MAX; } return \min( self::parseIniSize( \ini_get('upload_max_filesize') ), $postMaxSize, $memoryLimit ); }
php
private static function determineMaximumUploadSize() { $postMaxSize = self::parseIniSize( \ini_get('post_max_size') ); if ($postMaxSize <= 0) { $postMaxSize = \PHP_INT_MAX; } $memoryLimit = self::parseIniSize( \ini_get('memory_limit') ); if ($memoryLimit === -1) { $memoryLimit = \PHP_INT_MAX; } return \min( self::parseIniSize( \ini_get('upload_max_filesize') ), $postMaxSize, $memoryLimit ); }
[ "private", "static", "function", "determineMaximumUploadSize", "(", ")", "{", "$", "postMaxSize", "=", "self", "::", "parseIniSize", "(", "\\", "ini_get", "(", "'post_max_size'", ")", ")", ";", "if", "(", "$", "postMaxSize", "<=", "0", ")", "{", "$", "post...
Determines the maximum allowed size of file uploads as per PHP's configuration @return int the size in bytes
[ "Determines", "the", "maximum", "allowed", "size", "of", "file", "uploads", "as", "per", "PHP", "s", "configuration" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L252-L276
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.parseIniSize
private static function parseIniSize($sizeStr) { $sizeStr = \trim($sizeStr); $unitPrefix = \strtoupper( \substr($sizeStr, -1) ); $sizeInt = (int) $sizeStr; switch ($unitPrefix) { case 'K': $sizeInt *= 1024; break; case 'M': $sizeInt *= 1024 * 1024; break; case 'G': $sizeInt *= 1024 * 1024 * 1024; break; } return $sizeInt; }
php
private static function parseIniSize($sizeStr) { $sizeStr = \trim($sizeStr); $unitPrefix = \strtoupper( \substr($sizeStr, -1) ); $sizeInt = (int) $sizeStr; switch ($unitPrefix) { case 'K': $sizeInt *= 1024; break; case 'M': $sizeInt *= 1024 * 1024; break; case 'G': $sizeInt *= 1024 * 1024 * 1024; break; } return $sizeInt; }
[ "private", "static", "function", "parseIniSize", "(", "$", "sizeStr", ")", "{", "$", "sizeStr", "=", "\\", "trim", "(", "$", "sizeStr", ")", ";", "$", "unitPrefix", "=", "\\", "strtoupper", "(", "\\", "substr", "(", "$", "sizeStr", ",", "-", "1", ")"...
Parses a memory or storage size as found in the `php.ini` configuration file @param string $sizeStr the representation found in `php.ini` @return int the effective memory or storage size
[ "Parses", "a", "memory", "or", "storage", "size", "as", "found", "in", "the", "php", ".", "ini", "configuration", "file" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L284-L306
train
delight-im/PHP-FileUpload
src/AbstractUpload.php
AbstractUpload.parseIniBoolean
private static function parseIniBoolean($booleanStr) { if (empty($booleanStr)) { return false; } $booleanStr = \strtolower($booleanStr); if ($booleanStr === 'off' || $booleanStr === 'false' || $booleanStr === 'no' || $booleanStr === 'none') { return false; } if (((bool) $booleanStr) === false) { return false; } return true; }
php
private static function parseIniBoolean($booleanStr) { if (empty($booleanStr)) { return false; } $booleanStr = \strtolower($booleanStr); if ($booleanStr === 'off' || $booleanStr === 'false' || $booleanStr === 'no' || $booleanStr === 'none') { return false; } if (((bool) $booleanStr) === false) { return false; } return true; }
[ "private", "static", "function", "parseIniBoolean", "(", "$", "booleanStr", ")", "{", "if", "(", "empty", "(", "$", "booleanStr", ")", ")", "{", "return", "false", ";", "}", "$", "booleanStr", "=", "\\", "strtolower", "(", "$", "booleanStr", ")", ";", ...
Parses a boolean value as found in the `php.ini` configuration file @param string $booleanStr the representation found in `php.ini` @return bool the effective boolean value
[ "Parses", "a", "boolean", "value", "as", "found", "in", "the", "php", ".", "ini", "configuration", "file" ]
a793f4b9d6d2fc4ce57487c324a1547cce942cb6
https://github.com/delight-im/PHP-FileUpload/blob/a793f4b9d6d2fc4ce57487c324a1547cce942cb6/src/AbstractUpload.php#L314-L330
train
dereuromark/cakephp-tinyauth
src/Controller/Component/AuthComponent.php
AuthComponent._getAuth
protected function _getAuth($path = null) { if ($this->getConfig('autoClearCache') && Configure::read('debug')) { Cache::delete($this->getConfig('allowCacheKey'), $this->getConfig('cache')); } $roles = Cache::read($this->getConfig('allowCacheKey'), $this->getConfig('cache')); if ($roles !== false) { return $roles; } if ($path === null) { $path = $this->getConfig('allowFilePath'); } $iniArray = $this->_parseFiles($path, $this->getConfig('allowFile')); $res = []; foreach ($iniArray as $key => $actions) { $res[$key] = $this->_deconstructIniKey($key); $res[$key]['map'] = $actions; $actions = explode(',', $actions); if (in_array('*', $actions)) { $res[$key]['actions'] = []; continue; } foreach ($actions as $action) { $action = trim($action); if (!$action) { continue; } $res[$key]['actions'][] = $action; } } Cache::write($this->getConfig('allowCacheKey'), $res, $this->getConfig('cache')); return $res; }
php
protected function _getAuth($path = null) { if ($this->getConfig('autoClearCache') && Configure::read('debug')) { Cache::delete($this->getConfig('allowCacheKey'), $this->getConfig('cache')); } $roles = Cache::read($this->getConfig('allowCacheKey'), $this->getConfig('cache')); if ($roles !== false) { return $roles; } if ($path === null) { $path = $this->getConfig('allowFilePath'); } $iniArray = $this->_parseFiles($path, $this->getConfig('allowFile')); $res = []; foreach ($iniArray as $key => $actions) { $res[$key] = $this->_deconstructIniKey($key); $res[$key]['map'] = $actions; $actions = explode(',', $actions); if (in_array('*', $actions)) { $res[$key]['actions'] = []; continue; } foreach ($actions as $action) { $action = trim($action); if (!$action) { continue; } $res[$key]['actions'][] = $action; } } Cache::write($this->getConfig('allowCacheKey'), $res, $this->getConfig('cache')); return $res; }
[ "protected", "function", "_getAuth", "(", "$", "path", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getConfig", "(", "'autoClearCache'", ")", "&&", "Configure", "::", "read", "(", "'debug'", ")", ")", "{", "Cache", "::", "delete", "(", "$", ...
Parse ini file and returns the allowed actions. Uses cache for maximum performance. @param string|null $path @return array Actions
[ "Parse", "ini", "file", "and", "returns", "the", "allowed", "actions", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Controller/Component/AuthComponent.php#L122-L160
train
dereuromark/cakephp-tinyauth
src/Auth/AuthUserTrait.php
AuthUserTrait.isMe
public function isMe($userId) { $field = $this->getConfig('idColumn'); return $userId && (string)$userId === (string)$this->user($field); }
php
public function isMe($userId) { $field = $this->getConfig('idColumn'); return $userId && (string)$userId === (string)$this->user($field); }
[ "public", "function", "isMe", "(", "$", "userId", ")", "{", "$", "field", "=", "$", "this", "->", "getConfig", "(", "'idColumn'", ")", ";", "return", "$", "userId", "&&", "(", "string", ")", "$", "userId", "===", "(", "string", ")", "$", "this", "-...
This check can be used to tell if a record that belongs to some user is the current logged in user @param string|int $userId @return bool
[ "This", "check", "can", "be", "used", "to", "tell", "if", "a", "record", "that", "belongs", "to", "some", "user", "is", "the", "current", "logged", "in", "user" ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AuthUserTrait.php#L60-L63
train
dereuromark/cakephp-tinyauth
src/Auth/AuthUserTrait.php
AuthUserTrait.user
public function user($key = null) { $user = $this->_getUser(); if ($key === null) { return $user; } return Hash::get($user, $key); }
php
public function user($key = null) { $user = $this->_getUser(); if ($key === null) { return $user; } return Hash::get($user, $key); }
[ "public", "function", "user", "(", "$", "key", "=", "null", ")", "{", "$", "user", "=", "$", "this", "->", "_getUser", "(", ")", ";", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "user", ";", "}", "return", "Hash", "::", "get"...
Get the user data of the current session. @param string|null $key Key in dot syntax. @return mixed Data
[ "Get", "the", "user", "data", "of", "the", "current", "session", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AuthUserTrait.php#L71-L77
train
dereuromark/cakephp-tinyauth
src/Auth/AuthUserTrait.php
AuthUserTrait.hasRole
public function hasRole($expectedRole, $providedRoles = null) { if ($providedRoles !== null) { $roles = (array)$providedRoles; } else { $roles = $this->roles(); } if (!$roles) { return false; } if (array_key_exists($expectedRole, $roles) || in_array($expectedRole, $roles)) { return true; } return false; }
php
public function hasRole($expectedRole, $providedRoles = null) { if ($providedRoles !== null) { $roles = (array)$providedRoles; } else { $roles = $this->roles(); } if (!$roles) { return false; } if (array_key_exists($expectedRole, $roles) || in_array($expectedRole, $roles)) { return true; } return false; }
[ "public", "function", "hasRole", "(", "$", "expectedRole", ",", "$", "providedRoles", "=", "null", ")", "{", "if", "(", "$", "providedRoles", "!==", "null", ")", "{", "$", "roles", "=", "(", "array", ")", "$", "providedRoles", ";", "}", "else", "{", ...
Check if the current session has this role. @param mixed $expectedRole @param mixed|null $providedRoles @return bool Success
[ "Check", "if", "the", "current", "session", "has", "this", "role", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AuthUserTrait.php#L105-L120
train
dereuromark/cakephp-tinyauth
src/Auth/AuthUserTrait.php
AuthUserTrait.hasRoles
public function hasRoles($expectedRoles, $oneRoleIsEnough = true, $providedRoles = null) { if ($providedRoles !== null) { $roles = $providedRoles; } else { $roles = $this->roles(); } $expectedRoles = (array)$expectedRoles; if (!$expectedRoles) { return false; } $count = 0; foreach ($expectedRoles as $expectedRole) { if ($this->hasRole($expectedRole, $roles)) { if ($oneRoleIsEnough) { return true; } $count++; } else { if (!$oneRoleIsEnough) { return false; } } } if ($count === count($expectedRoles)) { return true; } return false; }
php
public function hasRoles($expectedRoles, $oneRoleIsEnough = true, $providedRoles = null) { if ($providedRoles !== null) { $roles = $providedRoles; } else { $roles = $this->roles(); } $expectedRoles = (array)$expectedRoles; if (!$expectedRoles) { return false; } $count = 0; foreach ($expectedRoles as $expectedRole) { if ($this->hasRole($expectedRole, $roles)) { if ($oneRoleIsEnough) { return true; } $count++; } else { if (!$oneRoleIsEnough) { return false; } } } if ($count === count($expectedRoles)) { return true; } return false; }
[ "public", "function", "hasRoles", "(", "$", "expectedRoles", ",", "$", "oneRoleIsEnough", "=", "true", ",", "$", "providedRoles", "=", "null", ")", "{", "if", "(", "$", "providedRoles", "!==", "null", ")", "{", "$", "roles", "=", "$", "providedRoles", ";...
Check if the current session has one of these roles. You can either require one of the roles (default), or you can require all roles to match. @param mixed $expectedRoles @param bool $oneRoleIsEnough (if all $roles have to match instead of just one) @param mixed|null $providedRoles @return bool Success
[ "Check", "if", "the", "current", "session", "has", "one", "of", "these", "roles", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AuthUserTrait.php#L133-L163
train
dereuromark/cakephp-tinyauth
src/Utility/Utility.php
Utility.deconstructIniKey
public static function deconstructIniKey($key) { $res = [ 'plugin' => null, 'prefix' => null ]; if (strpos($key, '.') !== false) { list($res['plugin'], $key) = explode('.', $key); } if (strpos($key, '/') !== false) { list($res['prefix'], $key) = explode('/', $key); } $res['controller'] = $key; return $res; }
php
public static function deconstructIniKey($key) { $res = [ 'plugin' => null, 'prefix' => null ]; if (strpos($key, '.') !== false) { list($res['plugin'], $key) = explode('.', $key); } if (strpos($key, '/') !== false) { list($res['prefix'], $key) = explode('/', $key); } $res['controller'] = $key; return $res; }
[ "public", "static", "function", "deconstructIniKey", "(", "$", "key", ")", "{", "$", "res", "=", "[", "'plugin'", "=>", "null", ",", "'prefix'", "=>", "null", "]", ";", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "!==", "false", ")", "{"...
Deconstructs an authentication ini section key into a named array with authentication parts. @param string $key INI section key as found in authentication.ini @return array Array with named keys for controller, plugin and prefix
[ "Deconstructs", "an", "authentication", "ini", "section", "key", "into", "a", "named", "array", "with", "authentication", "parts", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Utility/Utility.php#L14-L28
train
dereuromark/cakephp-tinyauth
src/Utility/Utility.php
Utility.parseFile
public static function parseFile($ini) { if (!file_exists($ini)) { throw new Exception(sprintf('Missing TinyAuth config file (%s)', $ini)); } if (function_exists('parse_ini_file')) { $iniArray = parse_ini_file($ini, true); } else { $content = file_get_contents($ini); if ($content === false) { throw new Exception('Cannot load INI file.'); } $iniArray = parse_ini_string($content, true); } if (!is_array($iniArray)) { throw new Exception(sprintf('Invalid TinyAuth config file (%s)', $ini)); } return $iniArray; }
php
public static function parseFile($ini) { if (!file_exists($ini)) { throw new Exception(sprintf('Missing TinyAuth config file (%s)', $ini)); } if (function_exists('parse_ini_file')) { $iniArray = parse_ini_file($ini, true); } else { $content = file_get_contents($ini); if ($content === false) { throw new Exception('Cannot load INI file.'); } $iniArray = parse_ini_string($content, true); } if (!is_array($iniArray)) { throw new Exception(sprintf('Invalid TinyAuth config file (%s)', $ini)); } return $iniArray; }
[ "public", "static", "function", "parseFile", "(", "$", "ini", ")", "{", "if", "(", "!", "file_exists", "(", "$", "ini", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Missing TinyAuth config file (%s)'", ",", "$", "ini", ")", ")", ";"...
Returns the ini file as an array. @param string $ini Full path to the ini file @return array List @throws \Cake\Core\Exception\Exception
[ "Returns", "the", "ini", "file", "as", "an", "array", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Utility/Utility.php#L57-L76
train
dereuromark/cakephp-tinyauth
src/Auth/AclTrait.php
AclTrait._loadAclAdapter
protected function _loadAclAdapter($adapter) { if (!class_exists($adapter)) { throw new Exception(sprintf('The Acl Adapter class "%s" was not found.', $adapter)); } $adapterInstance = new $adapter(); if (!($adapterInstance instanceof AclAdapterInterface)) { throw new InvalidArgumentException(sprintf( 'TinyAuth Acl adapters have to implement %s.', AclAdapterInterface::class )); } return $adapterInstance; }
php
protected function _loadAclAdapter($adapter) { if (!class_exists($adapter)) { throw new Exception(sprintf('The Acl Adapter class "%s" was not found.', $adapter)); } $adapterInstance = new $adapter(); if (!($adapterInstance instanceof AclAdapterInterface)) { throw new InvalidArgumentException(sprintf( 'TinyAuth Acl adapters have to implement %s.', AclAdapterInterface::class )); } return $adapterInstance; }
[ "protected", "function", "_loadAclAdapter", "(", "$", "adapter", ")", "{", "if", "(", "!", "class_exists", "(", "$", "adapter", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'The Acl Adapter class \"%s\" was not found.'", ",", "$", "adapter",...
Finds the Acl adapter to use for this request. @param string $adapter Acl adapter to load. @return \TinyAuth\Auth\AclAdapter\AclAdapterInterface @throws \Cake\Core\Exception\Exception @throws \InvalidArgumentException
[ "Finds", "the", "Acl", "adapter", "to", "use", "for", "this", "request", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AclTrait.php#L117-L130
train
dereuromark/cakephp-tinyauth
src/Auth/AclTrait.php
AclTrait._getAcl
protected function _getAcl($path = null) { if ($this->getConfig('autoClearCache') && Configure::read('debug')) { Cache::delete($this->getConfig('aclCacheKey'), $this->getConfig('cache')); } $roles = Cache::read($this->getConfig('aclCacheKey'), $this->getConfig('cache')); if ($roles !== false) { return $roles; } if ($path === null) { $path = $this->getConfig('aclFilePath'); } $config = $this->getConfig(); $config['filePath'] = $path; $config['file'] = $config['aclFile']; unset($config['aclFilePath']); unset($config['aclFile']); $roles = $this->_aclAdapter->getAcl($this->_getAvailableRoles(), $config); Cache::write($this->getConfig('aclCacheKey'), $roles, $this->getConfig('cache')); return $roles; }
php
protected function _getAcl($path = null) { if ($this->getConfig('autoClearCache') && Configure::read('debug')) { Cache::delete($this->getConfig('aclCacheKey'), $this->getConfig('cache')); } $roles = Cache::read($this->getConfig('aclCacheKey'), $this->getConfig('cache')); if ($roles !== false) { return $roles; } if ($path === null) { $path = $this->getConfig('aclFilePath'); } $config = $this->getConfig(); $config['filePath'] = $path; $config['file'] = $config['aclFile']; unset($config['aclFilePath']); unset($config['aclFile']); $roles = $this->_aclAdapter->getAcl($this->_getAvailableRoles(), $config); Cache::write($this->getConfig('aclCacheKey'), $roles, $this->getConfig('cache')); return $roles; }
[ "protected", "function", "_getAcl", "(", "$", "path", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getConfig", "(", "'autoClearCache'", ")", "&&", "Configure", "::", "read", "(", "'debug'", ")", ")", "{", "Cache", "::", "delete", "(", "$", "...
Parses INI file and returns the allowed roles per action. Uses cache for maximum performance. Improved speed by several actions before caching: - Resolves role slugs to their primary key / identifier - Resolves wildcards to their verbose translation @param string|array|null $path @return array Roles
[ "Parses", "INI", "file", "and", "returns", "the", "allowed", "roles", "per", "action", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AclTrait.php#L290-L312
train
dereuromark/cakephp-tinyauth
src/Auth/AclTrait.php
AclTrait._constructIniKey
protected function _constructIniKey($params) { $res = $params['controller']; if (!empty($params['prefix'])) { $res = $params['prefix'] . "/$res"; } if (!empty($params['plugin'])) { $res = $params['plugin'] . ".$res"; } return $res; }
php
protected function _constructIniKey($params) { $res = $params['controller']; if (!empty($params['prefix'])) { $res = $params['prefix'] . "/$res"; } if (!empty($params['plugin'])) { $res = $params['plugin'] . ".$res"; } return $res; }
[ "protected", "function", "_constructIniKey", "(", "$", "params", ")", "{", "$", "res", "=", "$", "params", "[", "'controller'", "]", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'prefix'", "]", ")", ")", "{", "$", "res", "=", "$", "param...
Constructs an ACL INI section key from a given Request. @param array $params The request params @return string Hash with named keys for controller, plugin and prefix
[ "Constructs", "an", "ACL", "INI", "section", "key", "from", "a", "given", "Request", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AclTrait.php#L341-L350
train
dereuromark/cakephp-tinyauth
src/Auth/AclTrait.php
AclTrait._getAvailableRoles
protected function _getAvailableRoles() { if ($this->_roles !== null) { return $this->_roles; } $roles = Configure::read($this->getConfig('rolesTable')); if (is_array($roles)) { if ($this->getConfig('superAdminRole')) { $key = $this->getConfig('superAdmin') ?: 'superadmin'; $roles[$key] = $this->getConfig('superAdminRole'); } return $roles; } $rolesTable = TableRegistry::get($this->getConfig('rolesTable')); $result = $rolesTable->find()->formatResults(function (ResultSetInterface $results) { return $results->combine($this->getConfig('aliasColumn'), 'id'); }); $roles = $result->toArray(); if ($this->getConfig('superAdminRole')) { $key = $this->getConfig('superAdmin') ?: 'superadmin'; $roles[$key] = $this->getConfig('superAdminRole'); } if (count($roles) < 1) { throw new Exception('Invalid TinyAuth role setup (roles table `' . $this->getConfig('rolesTable') . '` has no roles)'); } $this->_roles = $roles; return $roles; }
php
protected function _getAvailableRoles() { if ($this->_roles !== null) { return $this->_roles; } $roles = Configure::read($this->getConfig('rolesTable')); if (is_array($roles)) { if ($this->getConfig('superAdminRole')) { $key = $this->getConfig('superAdmin') ?: 'superadmin'; $roles[$key] = $this->getConfig('superAdminRole'); } return $roles; } $rolesTable = TableRegistry::get($this->getConfig('rolesTable')); $result = $rolesTable->find()->formatResults(function (ResultSetInterface $results) { return $results->combine($this->getConfig('aliasColumn'), 'id'); }); $roles = $result->toArray(); if ($this->getConfig('superAdminRole')) { $key = $this->getConfig('superAdmin') ?: 'superadmin'; $roles[$key] = $this->getConfig('superAdminRole'); } if (count($roles) < 1) { throw new Exception('Invalid TinyAuth role setup (roles table `' . $this->getConfig('rolesTable') . '` has no roles)'); } $this->_roles = $roles; return $roles; }
[ "protected", "function", "_getAvailableRoles", "(", ")", "{", "if", "(", "$", "this", "->", "_roles", "!==", "null", ")", "{", "return", "$", "this", "->", "_roles", ";", "}", "$", "roles", "=", "Configure", "::", "read", "(", "$", "this", "->", "get...
Returns a list of all available roles. Will look for a roles array in Configure first, tries database roles table next. @return array List with all available roles @throws \Cake\Core\Exception\Exception
[ "Returns", "a", "list", "of", "all", "available", "roles", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AclTrait.php#L361-L393
train
dereuromark/cakephp-tinyauth
src/Auth/AclTrait.php
AclTrait._getUserRoles
protected function _getUserRoles($user) { // Single-role from session if (!$this->getConfig('multiRole')) { if (!array_key_exists($this->getConfig('roleColumn'), $user)) { throw new Exception(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $this->getConfig('roleColumn'))); } if (!isset($user[$this->getConfig('roleColumn')])) { return []; } return $this->_mapped([$user[$this->getConfig('roleColumn')]]); } // Multi-role from session if (isset($user[$this->getConfig('rolesTable')])) { $userRoles = $user[$this->getConfig('rolesTable')]; if (isset($userRoles[0]['id'])) { $userRoles = Hash::extract($userRoles, '{n}.id'); } return $this->_mapped((array)$userRoles); } // Multi-role from session via pivot table $pivotTableName = $this->getConfig('pivotTable'); if (!$pivotTableName) { list(, $rolesTableName) = pluginSplit($this->getConfig('rolesTable')); list(, $usersTableName) = pluginSplit($this->getConfig('usersTable')); $tables = [ $usersTableName, $rolesTableName ]; asort($tables); $pivotTableName = implode('', $tables); } if (isset($user[$pivotTableName])) { $userRoles = $user[$pivotTableName]; if (isset($userRoles[0][$this->getConfig('roleColumn')])) { $userRoles = Hash::extract($userRoles, '{n}.' . $this->getConfig('roleColumn')); } return $this->_mapped((array)$userRoles); } // Multi-role from DB: load the pivot table $roles = $this->_getRolesFromDb($pivotTableName, $user[$this->getConfig('idColumn')]); if (!$roles) { return []; } return $this->_mapped($roles); }
php
protected function _getUserRoles($user) { // Single-role from session if (!$this->getConfig('multiRole')) { if (!array_key_exists($this->getConfig('roleColumn'), $user)) { throw new Exception(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $this->getConfig('roleColumn'))); } if (!isset($user[$this->getConfig('roleColumn')])) { return []; } return $this->_mapped([$user[$this->getConfig('roleColumn')]]); } // Multi-role from session if (isset($user[$this->getConfig('rolesTable')])) { $userRoles = $user[$this->getConfig('rolesTable')]; if (isset($userRoles[0]['id'])) { $userRoles = Hash::extract($userRoles, '{n}.id'); } return $this->_mapped((array)$userRoles); } // Multi-role from session via pivot table $pivotTableName = $this->getConfig('pivotTable'); if (!$pivotTableName) { list(, $rolesTableName) = pluginSplit($this->getConfig('rolesTable')); list(, $usersTableName) = pluginSplit($this->getConfig('usersTable')); $tables = [ $usersTableName, $rolesTableName ]; asort($tables); $pivotTableName = implode('', $tables); } if (isset($user[$pivotTableName])) { $userRoles = $user[$pivotTableName]; if (isset($userRoles[0][$this->getConfig('roleColumn')])) { $userRoles = Hash::extract($userRoles, '{n}.' . $this->getConfig('roleColumn')); } return $this->_mapped((array)$userRoles); } // Multi-role from DB: load the pivot table $roles = $this->_getRolesFromDb($pivotTableName, $user[$this->getConfig('idColumn')]); if (!$roles) { return []; } return $this->_mapped($roles); }
[ "protected", "function", "_getUserRoles", "(", "$", "user", ")", "{", "// Single-role from session", "if", "(", "!", "$", "this", "->", "getConfig", "(", "'multiRole'", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "getConfig", ...
Returns a list of all roles belonging to the authenticated user. Lookup in the following order: - single role id using the roleColumn in single-role mode - direct lookup in the pivot table (to support both Configure and Model in multi-role mode) @param array $user The user to get the roles for @return array List with all role ids belonging to the user @throws \Cake\Core\Exception\Exception
[ "Returns", "a", "list", "of", "all", "roles", "belonging", "to", "the", "authenticated", "user", "." ]
a5ce544d93f28a5d3aecc141e3fd59dafef90521
https://github.com/dereuromark/cakephp-tinyauth/blob/a5ce544d93f28a5d3aecc141e3fd59dafef90521/src/Auth/AclTrait.php#L407-L455
train
spatie/laravel-partialcache
src/PartialCache.php
PartialCache.cache
public function cache($data, $view, $mergeData = null, $minutes = null, $key = null, $tag = null) { if (! $this->enabled) { return call_user_func($this->renderView($view, $data, $mergeData)); } $viewKey = $this->getCacheKeyForView($view, $key); $mergeData = $mergeData ?: []; $tags = $this->getTags($tag); $minutes = $this->resolveCacheDuration($minutes); if ($this->cacheIsTaggable && $minutes === null) { return $this->cache ->tags($tags) ->rememberForever($viewKey, $this->renderView($view, $data, $mergeData)); } if ($this->cacheIsTaggable) { return $this->cache ->tags($tags) ->remember($viewKey, $minutes, $this->renderView($view, $data, $mergeData)); } if ($minutes === null) { return $this->cache ->rememberForever($viewKey, $this->renderView($view, $data, $mergeData)); } return $this->cache ->remember($viewKey, $minutes, $this->renderView($view, $data, $mergeData)); }
php
public function cache($data, $view, $mergeData = null, $minutes = null, $key = null, $tag = null) { if (! $this->enabled) { return call_user_func($this->renderView($view, $data, $mergeData)); } $viewKey = $this->getCacheKeyForView($view, $key); $mergeData = $mergeData ?: []; $tags = $this->getTags($tag); $minutes = $this->resolveCacheDuration($minutes); if ($this->cacheIsTaggable && $minutes === null) { return $this->cache ->tags($tags) ->rememberForever($viewKey, $this->renderView($view, $data, $mergeData)); } if ($this->cacheIsTaggable) { return $this->cache ->tags($tags) ->remember($viewKey, $minutes, $this->renderView($view, $data, $mergeData)); } if ($minutes === null) { return $this->cache ->rememberForever($viewKey, $this->renderView($view, $data, $mergeData)); } return $this->cache ->remember($viewKey, $minutes, $this->renderView($view, $data, $mergeData)); }
[ "public", "function", "cache", "(", "$", "data", ",", "$", "view", ",", "$", "mergeData", "=", "null", ",", "$", "minutes", "=", "null", ",", "$", "key", "=", "null", ",", "$", "tag", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", ...
Cache a view. If minutes are null, the view is cached forever. @param array $data @param string $view @param array $mergeData @param int $minutes @param string $key @param string|array $tag @return string
[ "Cache", "a", "view", ".", "If", "minutes", "are", "null", "the", "view", "is", "cached", "forever", "." ]
1e0d24a8c2f0f53a23a59f81a3af41ba9089914c
https://github.com/spatie/laravel-partialcache/blob/1e0d24a8c2f0f53a23a59f81a3af41ba9089914c/src/PartialCache.php#L59-L92
train
spatie/laravel-partialcache
src/PartialCache.php
PartialCache.getCacheKeyForView
public function getCacheKeyForView($view, $key = null) { $parts = [$this->cacheKey, $view]; if ($key !== null) { $parts[] = $key; } return implode('.', $parts); }
php
public function getCacheKeyForView($view, $key = null) { $parts = [$this->cacheKey, $view]; if ($key !== null) { $parts[] = $key; } return implode('.', $parts); }
[ "public", "function", "getCacheKeyForView", "(", "$", "view", ",", "$", "key", "=", "null", ")", "{", "$", "parts", "=", "[", "$", "this", "->", "cacheKey", ",", "$", "view", "]", ";", "if", "(", "$", "key", "!==", "null", ")", "{", "$", "parts",...
Create a key name for the cached view. @param string $view @param string $key @return string
[ "Create", "a", "key", "name", "for", "the", "cached", "view", "." ]
1e0d24a8c2f0f53a23a59f81a3af41ba9089914c
https://github.com/spatie/laravel-partialcache/blob/1e0d24a8c2f0f53a23a59f81a3af41ba9089914c/src/PartialCache.php#L102-L111
train
spatie/laravel-partialcache
src/PartialCache.php
PartialCache.forget
public function forget($view, $key = null, $tag = null) { $cacheKey = $this->getCacheKeyForView($view, $key); if ($this->cacheIsTaggable) { $tags = $this->getTags($tag); $this->cache->tags($tags)->forget($cacheKey); } $this->cache->forget($cacheKey); }
php
public function forget($view, $key = null, $tag = null) { $cacheKey = $this->getCacheKeyForView($view, $key); if ($this->cacheIsTaggable) { $tags = $this->getTags($tag); $this->cache->tags($tags)->forget($cacheKey); } $this->cache->forget($cacheKey); }
[ "public", "function", "forget", "(", "$", "view", ",", "$", "key", "=", "null", ",", "$", "tag", "=", "null", ")", "{", "$", "cacheKey", "=", "$", "this", "->", "getCacheKeyForView", "(", "$", "view", ",", "$", "key", ")", ";", "if", "(", "$", ...
Forget a rendered view. @param string $view @param string $key @param null|string|array $tag
[ "Forget", "a", "rendered", "view", "." ]
1e0d24a8c2f0f53a23a59f81a3af41ba9089914c
https://github.com/spatie/laravel-partialcache/blob/1e0d24a8c2f0f53a23a59f81a3af41ba9089914c/src/PartialCache.php#L120-L130
train
spatie/laravel-partialcache
src/PartialCache.php
PartialCache.getTags
protected function getTags($tag = null) { $tags = [$this->cacheKey]; if ($tag) { if (! is_array($tag)) { $tag = [$tag]; } $tags = array_merge($tags, $tag); } return $tags; }
php
protected function getTags($tag = null) { $tags = [$this->cacheKey]; if ($tag) { if (! is_array($tag)) { $tag = [$tag]; } $tags = array_merge($tags, $tag); } return $tags; }
[ "protected", "function", "getTags", "(", "$", "tag", "=", "null", ")", "{", "$", "tags", "=", "[", "$", "this", "->", "cacheKey", "]", ";", "if", "(", "$", "tag", ")", "{", "if", "(", "!", "is_array", "(", "$", "tag", ")", ")", "{", "$", "tag...
Constructs tag array. @param null|string|array $tag @return array
[ "Constructs", "tag", "array", "." ]
1e0d24a8c2f0f53a23a59f81a3af41ba9089914c
https://github.com/spatie/laravel-partialcache/blob/1e0d24a8c2f0f53a23a59f81a3af41ba9089914c/src/PartialCache.php#L177-L190
train
datto/php-json-rpc-http
src/Client.php
Client.setHeader
public function setHeader($name, $value) { if (!self::isValidHeader($name, $value)) { return false; } if (isset($this->requiredHttpHeaders[$name])) { return $this->requiredHttpHeaders[$name] === $value; } $this->headers[$name] = $value; return true; }
php
public function setHeader($name, $value) { if (!self::isValidHeader($name, $value)) { return false; } if (isset($this->requiredHttpHeaders[$name])) { return $this->requiredHttpHeaders[$name] === $value; } $this->headers[$name] = $value; return true; }
[ "public", "function", "setHeader", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "self", "::", "isValidHeader", "(", "$", "name", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this"...
Set add an additional HTTP header. This additional header will be sent on each future HTTP request. @param string $name The name of the HTTP header (e.g. "Authorization"). @param string $value The value of this HTTP header (e.g. "Basic YmFzaWM6YXV0aGVudGljYXRpb24="). @return boolean True iff the header has been set successfully (or has had the desired value all along). Note that the CONTENT_TYPE, CONNECTION_TYPE, and METHOD headers cannot be changed, because those headers are required.
[ "Set", "add", "an", "additional", "HTTP", "header", ".", "This", "additional", "header", "will", "be", "sent", "on", "each", "future", "HTTP", "request", "." ]
426aee88743f8c04b2b1b2ee30f89bd3a477ed18
https://github.com/datto/php-json-rpc-http/blob/426aee88743f8c04b2b1b2ee30f89bd3a477ed18/src/Client.php#L254-L267
train
datto/php-json-rpc-http
src/Client.php
Client.unsetHeader
public function unsetHeader($name) { if (!self::isValidHeaderName($name)) { return true; } if (isset($this->requiredHttpHeaders[$name])) { return false; } unset($this->headers[$name]); return true; }
php
public function unsetHeader($name) { if (!self::isValidHeaderName($name)) { return true; } if (isset($this->requiredHttpHeaders[$name])) { return false; } unset($this->headers[$name]); return true; }
[ "public", "function", "unsetHeader", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "isValidHeaderName", "(", "$", "name", ")", ")", "{", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "requiredHttpHeaders", "[", "...
Unset an existing HTTP header. This HTTP header will no longer be sent on future requests. @param string $name The name of the HTTP header (e.g. "Authorization"). @return boolean True iff the header was successfully removed (or was never set in the first place). Note that the CONTENT_TYPE, CONNECTION_TYPE, and METHOD headers are required, so those headers cannot be unset.
[ "Unset", "an", "existing", "HTTP", "header", ".", "This", "HTTP", "header", "will", "no", "longer", "be", "sent", "on", "future", "requests", "." ]
426aee88743f8c04b2b1b2ee30f89bd3a477ed18
https://github.com/datto/php-json-rpc-http/blob/426aee88743f8c04b2b1b2ee30f89bd3a477ed18/src/Client.php#L281-L293
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.getConstraints
protected function getConstraints(Builder $builder, array $query) { $constraints = []; foreach ($query as $field => $values) { if ($this->isFieldSearchable($builder, $field)) { $constraints[$field] = $this->buildConstraints($values); } } return $constraints; }
php
protected function getConstraints(Builder $builder, array $query) { $constraints = []; foreach ($query as $field => $values) { if ($this->isFieldSearchable($builder, $field)) { $constraints[$field] = $this->buildConstraints($values); } } return $constraints; }
[ "protected", "function", "getConstraints", "(", "Builder", "$", "builder", ",", "array", "$", "query", ")", "{", "$", "constraints", "=", "[", "]", ";", "foreach", "(", "$", "query", "as", "$", "field", "=>", "$", "values", ")", "{", "if", "(", "$", ...
Builds search constraints based on model's searchable fields and query parameters. @param Builder $builder query builder @param array $query query parameters @return array
[ "Builds", "search", "constraints", "based", "on", "model", "s", "searchable", "fields", "and", "query", "parameters", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L42-L52
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.validateFieldNames
protected function validateFieldNames(array $query) { foreach ($query as $field => $values) { if (!preg_match('/^!?[a-zA-Z0-9\-_:]+$/', $field)) { throw new InvalidArgumentException(sprintf('Incorrect field name: %s', $field)); } } }
php
protected function validateFieldNames(array $query) { foreach ($query as $field => $values) { if (!preg_match('/^!?[a-zA-Z0-9\-_:]+$/', $field)) { throw new InvalidArgumentException(sprintf('Incorrect field name: %s', $field)); } } }
[ "protected", "function", "validateFieldNames", "(", "array", "$", "query", ")", "{", "foreach", "(", "$", "query", "as", "$", "field", "=>", "$", "values", ")", "{", "if", "(", "!", "preg_match", "(", "'/^!?[a-zA-Z0-9\\-_:]+$/'", ",", "$", "field", ")", ...
Makes sure field names contain only allowed characters @param array $query
[ "Makes", "sure", "field", "names", "contain", "only", "allowed", "characters" ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L59-L65
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.isFieldSearchable
protected function isFieldSearchable(Builder $builder, $field) { $searchable = $this->_getSearchableAttributes($builder); $notSearchable = $this->_getNotSearchableAttributes($builder); $field = preg_replace('#^!#', '', $field); return !in_array($field, $notSearchable) && !in_array('*', $notSearchable) && (in_array($field, $searchable) || in_array('*', $searchable)); }
php
protected function isFieldSearchable(Builder $builder, $field) { $searchable = $this->_getSearchableAttributes($builder); $notSearchable = $this->_getNotSearchableAttributes($builder); $field = preg_replace('#^!#', '', $field); return !in_array($field, $notSearchable) && !in_array('*', $notSearchable) && (in_array($field, $searchable) || in_array('*', $searchable)); }
[ "protected", "function", "isFieldSearchable", "(", "Builder", "$", "builder", ",", "$", "field", ")", "{", "$", "searchable", "=", "$", "this", "->", "_getSearchableAttributes", "(", "$", "builder", ")", ";", "$", "notSearchable", "=", "$", "this", "->", "...
Check if field is searchable for given model. @param Builder $builder query builder @param string $field field name @return bool
[ "Check", "if", "field", "is", "searchable", "for", "given", "model", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L75-L83
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.applyConstraints
protected function applyConstraints(Builder $builder, array $constraints, $mode = Constraint::MODE_AND) { foreach ($constraints as $field => $constraint) { if (is_array($constraint)) { foreach ($constraint as $single_constraint) { $this->applyConstraint($builder, $field, $single_constraint, $mode); } } else { $this->applyConstraint($builder, $field, $constraint, $mode); } } }
php
protected function applyConstraints(Builder $builder, array $constraints, $mode = Constraint::MODE_AND) { foreach ($constraints as $field => $constraint) { if (is_array($constraint)) { foreach ($constraint as $single_constraint) { $this->applyConstraint($builder, $field, $single_constraint, $mode); } } else { $this->applyConstraint($builder, $field, $constraint, $mode); } } }
[ "protected", "function", "applyConstraints", "(", "Builder", "$", "builder", ",", "array", "$", "constraints", ",", "$", "mode", "=", "Constraint", "::", "MODE_AND", ")", "{", "foreach", "(", "$", "constraints", "as", "$", "field", "=>", "$", "constraint", ...
Applies constraints to query, allowing model to overwrite any of them. @param Builder $builder query builder @param Constraint[] $constraints constraints @param string $mode determines how constraints are applied ("or" or "and")
[ "Applies", "constraints", "to", "query", "allowing", "model", "to", "overwrite", "any", "of", "them", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L92-L103
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.callInterceptor
protected function callInterceptor(Builder $builder, $field, Constraint $constraint) { $model = $builder->getModel(); $interceptor = sprintf('process%sFilter', str_replace(':', '_', Str::studly($field))); if (method_exists($model, $interceptor)) { if ($model->$interceptor($builder, $constraint)) { return true; } } return false; }
php
protected function callInterceptor(Builder $builder, $field, Constraint $constraint) { $model = $builder->getModel(); $interceptor = sprintf('process%sFilter', str_replace(':', '_', Str::studly($field))); if (method_exists($model, $interceptor)) { if ($model->$interceptor($builder, $constraint)) { return true; } } return false; }
[ "protected", "function", "callInterceptor", "(", "Builder", "$", "builder", ",", "$", "field", ",", "Constraint", "$", "constraint", ")", "{", "$", "model", "=", "$", "builder", "->", "getModel", "(", ")", ";", "$", "interceptor", "=", "sprintf", "(", "'...
Calls constraint interceptor on model. @param Builder $builder query builder @param string $field field on which constraint is applied @param Constraint $constraint constraint @return bool true if constraint was intercepted by model's method
[ "Calls", "constraint", "interceptor", "on", "model", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L114-L126
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.buildConstraints
protected function buildConstraints($values) { if (is_array($values)) { $constraints = []; foreach ($values as $value) { $constraints[] = Constraint::make($value); } return $constraints; } else { return Constraint::make($values); } }
php
protected function buildConstraints($values) { if (is_array($values)) { $constraints = []; foreach ($values as $value) { $constraints[] = Constraint::make($value); } return $constraints; } else { return Constraint::make($values); } }
[ "protected", "function", "buildConstraints", "(", "$", "values", ")", "{", "if", "(", "is_array", "(", "$", "values", ")", ")", "{", "$", "constraints", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "constraint...
Build Constraint objects from given filter values @param string []|string @return Constraint[]|Constraint
[ "Build", "Constraint", "objects", "from", "given", "filter", "values" ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L135-L146
train
jedrzej/searchable
src/Jedrzej/Searchable/SearchableTrait.php
SearchableTrait.applyConstraint
protected function applyConstraint(Builder $builder, $field, $constraint, $mode = Constraint::MODE_AND) { // let model handle the constraint if it has the interceptor if (!$this->callInterceptor($builder, $field, $constraint)) { $constraint->apply($builder, $field, $mode); } }
php
protected function applyConstraint(Builder $builder, $field, $constraint, $mode = Constraint::MODE_AND) { // let model handle the constraint if it has the interceptor if (!$this->callInterceptor($builder, $field, $constraint)) { $constraint->apply($builder, $field, $mode); } }
[ "protected", "function", "applyConstraint", "(", "Builder", "$", "builder", ",", "$", "field", ",", "$", "constraint", ",", "$", "mode", "=", "Constraint", "::", "MODE_AND", ")", "{", "// let model handle the constraint if it has the interceptor", "if", "(", "!", ...
Apply a single constraint - either directly or using model's interceptor @param Builder $builder query builder @param string $field field name @param Constraint $constraint constraint @param string $mode determines how constraint is applied ("or" or "and")
[ "Apply", "a", "single", "constraint", "-", "either", "directly", "or", "using", "model", "s", "interceptor" ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L156-L162
train
jedrzej/searchable
src/Jedrzej/Searchable/Constraint.php
Constraint.make
public static function make($value) { $value = static::prepareValue($value); $is_negation = static::parseIsNegation($value); list($operator, $value) = static::parseOperatorAndValue($value, $is_negation); return new static($operator, $value, $is_negation); }
php
public static function make($value) { $value = static::prepareValue($value); $is_negation = static::parseIsNegation($value); list($operator, $value) = static::parseOperatorAndValue($value, $is_negation); return new static($operator, $value, $is_negation); }
[ "public", "static", "function", "make", "(", "$", "value", ")", "{", "$", "value", "=", "static", "::", "prepareValue", "(", "$", "value", ")", ";", "$", "is_negation", "=", "static", "::", "parseIsNegation", "(", "$", "value", ")", ";", "list", "(", ...
Creates constraint object for given filter. @param string $value query value @return Constraint
[ "Creates", "constraint", "object", "for", "given", "filter", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L66-L73
train
jedrzej/searchable
src/Jedrzej/Searchable/Constraint.php
Constraint.apply
public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND) { if ($this->isRelation($field)) { list($relation, $field) = $this->splitRelationField($field); if (static::parseIsNegation($relation)) { $builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) { $this->doApply($builder, $field, $mode); }); } else { $builder->whereHas($relation, function (Builder $builder) use ($field, $mode) { $this->doApply($builder, $field, $mode); }); } } else { $this->doApply($builder, $field, $mode); } }
php
public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND) { if ($this->isRelation($field)) { list($relation, $field) = $this->splitRelationField($field); if (static::parseIsNegation($relation)) { $builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) { $this->doApply($builder, $field, $mode); }); } else { $builder->whereHas($relation, function (Builder $builder) use ($field, $mode) { $this->doApply($builder, $field, $mode); }); } } else { $this->doApply($builder, $field, $mode); } }
[ "public", "function", "apply", "(", "Builder", "$", "builder", ",", "$", "field", ",", "$", "mode", "=", "Constraint", "::", "MODE_AND", ")", "{", "if", "(", "$", "this", "->", "isRelation", "(", "$", "field", ")", ")", "{", "list", "(", "$", "rela...
Applies constraint to query. @param Builder $builder query builder @param string $field field name @param string $mode determines how constraint is added to existing query ("or" or "and")
[ "Applies", "constraint", "to", "query", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L82-L98
train
jedrzej/searchable
src/Jedrzej/Searchable/Constraint.php
Constraint.splitRelationField
protected function splitRelationField($field) { $parts = explode(':', $field); $partsCount = count($parts); return [implode('.', array_slice($parts, 0, $partsCount - 1)), $parts[$partsCount - 1]]; }
php
protected function splitRelationField($field) { $parts = explode(':', $field); $partsCount = count($parts); return [implode('.', array_slice($parts, 0, $partsCount - 1)), $parts[$partsCount - 1]]; }
[ "protected", "function", "splitRelationField", "(", "$", "field", ")", "{", "$", "parts", "=", "explode", "(", "':'", ",", "$", "field", ")", ";", "$", "partsCount", "=", "count", "(", "$", "parts", ")", ";", "return", "[", "implode", "(", "'.'", ","...
Splits given field name containing relation name into relation name and field name @param string $field field name @return array relation name at index 0, field name at index 1
[ "Splits", "given", "field", "name", "containing", "relation", "name", "into", "relation", "name", "and", "field", "name" ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L116-L122
train
jedrzej/searchable
src/Jedrzej/Searchable/Constraint.php
Constraint.doApply
protected function doApply(Builder $builder, $field, $mode = Constraint::MODE_AND) { if ($this->operator == Constraint::OPERATOR_IN) { $method = $mode != static::MODE_OR ? 'whereIn' : 'orWhereIn'; $builder->$method($field, $this->value); } elseif ($this->operator == Constraint::OPERATOR_NOT_IN) { $method = $mode != static::MODE_OR ? 'whereNotIn' : 'orWhereNotIn'; $builder->$method($field, $this->value); } elseif ($this->operator == Constraint::OPERATOR_NOT_NULL) { $method = $mode != static::MODE_OR ? 'whereNotNull' : 'orWhereNotNull'; $builder->$method($field); } elseif ($this->operator == Constraint::OPERATOR_NULL) { $method = $mode != static::MODE_OR ? 'whereNull' : 'orWhereNull'; $builder->$method($field); } else { $method = $mode != static::MODE_OR ? 'where' : 'orWhere'; $builder->$method($field, $this->operator, $this->value); } }
php
protected function doApply(Builder $builder, $field, $mode = Constraint::MODE_AND) { if ($this->operator == Constraint::OPERATOR_IN) { $method = $mode != static::MODE_OR ? 'whereIn' : 'orWhereIn'; $builder->$method($field, $this->value); } elseif ($this->operator == Constraint::OPERATOR_NOT_IN) { $method = $mode != static::MODE_OR ? 'whereNotIn' : 'orWhereNotIn'; $builder->$method($field, $this->value); } elseif ($this->operator == Constraint::OPERATOR_NOT_NULL) { $method = $mode != static::MODE_OR ? 'whereNotNull' : 'orWhereNotNull'; $builder->$method($field); } elseif ($this->operator == Constraint::OPERATOR_NULL) { $method = $mode != static::MODE_OR ? 'whereNull' : 'orWhereNull'; $builder->$method($field); } else { $method = $mode != static::MODE_OR ? 'where' : 'orWhere'; $builder->$method($field, $this->operator, $this->value); } }
[ "protected", "function", "doApply", "(", "Builder", "$", "builder", ",", "$", "field", ",", "$", "mode", "=", "Constraint", "::", "MODE_AND", ")", "{", "if", "(", "$", "this", "->", "operator", "==", "Constraint", "::", "OPERATOR_IN", ")", "{", "$", "m...
Applies non-relation constraint to query. @param Builder $builder query builder @param string $field field name @param string $mode determines how constraint is added to existing query ("or" or "and")
[ "Applies", "non", "-", "relation", "constraint", "to", "query", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L131-L149
train
jedrzej/searchable
src/Jedrzej/Searchable/Constraint.php
Constraint.parseOperatorAndValue
protected static function parseOperatorAndValue($value, $is_negation) { if ($result = static::parseComparisonOperator($value, $is_negation)) { return $result; } if ($result = static::parseLikeOperator($value, $is_negation)) { return $result; } if ($result = static::parseNullOperator($value, $is_negation)) { return $result; } if ($result = static::parseEqualsInOperator($value, $is_negation)) { return $result; } throw new InvalidArgumentException(sprintf('Unable to parse operator or value from "%s"', $value)); }
php
protected static function parseOperatorAndValue($value, $is_negation) { if ($result = static::parseComparisonOperator($value, $is_negation)) { return $result; } if ($result = static::parseLikeOperator($value, $is_negation)) { return $result; } if ($result = static::parseNullOperator($value, $is_negation)) { return $result; } if ($result = static::parseEqualsInOperator($value, $is_negation)) { return $result; } throw new InvalidArgumentException(sprintf('Unable to parse operator or value from "%s"', $value)); }
[ "protected", "static", "function", "parseOperatorAndValue", "(", "$", "value", ",", "$", "is_negation", ")", "{", "if", "(", "$", "result", "=", "static", "::", "parseComparisonOperator", "(", "$", "value", ",", "$", "is_negation", ")", ")", "{", "return", ...
Parse query parameter and get operator and value. @param string $value @param bool $is_negation @return string[] @throws InvalidArgumentException when unable to parse operator or value
[ "Parse", "query", "parameter", "and", "get", "operator", "and", "value", "." ]
1f7912406172f9f210c906d401134cb33215a0d0
https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L203-L222
train
filestack/filestack-php
filestack/Filelink.php
Filelink.ascii
public function ascii($background = 'white', $colored = false, $foreground='red', $reverse = false, $size = 100) { $options = [ 'b' => $background, 'c' => $colored ? 'true' : 'false', 'f' => $foreground, 'r' => $reverse ? 'true' : 'false', 's' => $size ]; // call TransformationMixin function $this->setTransformUrl('ascii', $options); return $this; }
php
public function ascii($background = 'white', $colored = false, $foreground='red', $reverse = false, $size = 100) { $options = [ 'b' => $background, 'c' => $colored ? 'true' : 'false', 'f' => $foreground, 'r' => $reverse ? 'true' : 'false', 's' => $size ]; // call TransformationMixin function $this->setTransformUrl('ascii', $options); return $this; }
[ "public", "function", "ascii", "(", "$", "background", "=", "'white'", ",", "$", "colored", "=", "false", ",", "$", "foreground", "=", "'red'", ",", "$", "reverse", "=", "false", ",", "$", "size", "=", "100", ")", "{", "$", "options", "=", "[", "'b...
Set this Filelink's transform_url to include ascii task @param string $background background color of the HTML file. This can be the word for a color hex value e.g. ('black' or '000000') @param bool $colored Reproduces the colors in the original image if set to true. @param string $foreground Specifies the font color of ASCII images. Only works in non-colored mode. @param bool $reverse Reverses the character set used to generate the ASCII output. Requires colored:true. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "ascii", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L70-L85
train
filestack/filestack-php
filestack/Filelink.php
Filelink.border
public function border($background = 'white', $color = 'black', $width=2) { $options = [ 'b' => $background, 'c' => $color, 'w' => $width ]; // call TransformationMixin function $this->setTransformUrl('border', $options); return $this; }
php
public function border($background = 'white', $color = 'black', $width=2) { $options = [ 'b' => $background, 'c' => $color, 'w' => $width ]; // call TransformationMixin function $this->setTransformUrl('border', $options); return $this; }
[ "public", "function", "border", "(", "$", "background", "=", "'white'", ",", "$", "color", "=", "'black'", ",", "$", "width", "=", "2", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "background", ",", "'c'", "=>", "$", "color", ",", "'w'", ...
Set this Filelink's transform_url to include border task @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param string $color Sets the color of the border to render around the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param int $width Sets the width in pixels of the border to render around the image. The value for this parameter must be in a range from 1 to 1000. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "border", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L142-L154
train
filestack/filestack-php
filestack/Filelink.php
Filelink.modulate
public function modulate($brightness = 100, $hue = 0, $saturation = 100) { $options = [ 'b' => $brightness, 'h' => $hue, 's' => $saturation ]; // call TransformationMixin function $this->setTransformUrl('modulate', $options); return $this; }
php
public function modulate($brightness = 100, $hue = 0, $saturation = 100) { $options = [ 'b' => $brightness, 'h' => $hue, 's' => $saturation ]; // call TransformationMixin function $this->setTransformUrl('modulate', $options); return $this; }
[ "public", "function", "modulate", "(", "$", "brightness", "=", "100", ",", "$", "hue", "=", "0", ",", "$", "saturation", "=", "100", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "brightness", ",", "'h'", "=>", "$", "hue", ",", "'s'", "=>...
Set this Filelink's transform_url to include the modulate task @param int $brightness The amount to change the brightness of an image. The value range is 0 to 10000. @param int $hue The degree to set the hue to. The value range is 0 - 359, where 0 is the equivalent of red and 180 is the equivalent of cyan. @param int $saturation The amount to change the saturation of image. The value range is 0 to 10000. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "modulate", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L625-L637
train
filestack/filestack-php
filestack/Filelink.php
Filelink.partialBlur
public function partialBlur($amount = 10, $blur = 4, $objects = [], $type = 'rect') { $options = [ 'a' => $amount, 'l' => $blur, 'o' => $objects, 't' => $type ]; // call TransformationMixin function $this->setTransformUrl('partial_blur', $options); return $this; }
php
public function partialBlur($amount = 10, $blur = 4, $objects = [], $type = 'rect') { $options = [ 'a' => $amount, 'l' => $blur, 'o' => $objects, 't' => $type ]; // call TransformationMixin function $this->setTransformUrl('partial_blur', $options); return $this; }
[ "public", "function", "partialBlur", "(", "$", "amount", "=", "10", ",", "$", "blur", "=", "4", ",", "$", "objects", "=", "[", "]", ",", "$", "type", "=", "'rect'", ")", "{", "$", "options", "=", "[", "'a'", "=>", "$", "amount", ",", "'l'", "=>...
Set this Filelink's transform_url to include the partial_blur task @param int $amount The amount to blur the image. Range is 1 to 20 @param int $blur The amount to blur the image. Range is 0 to 20. @param array $objects The area(s) of the image to blur. This variable is an array of arrays. Each array input for this parameter defines a different section of the image and must have exactly 4 integers: 'x coordinate,y coordinate,width,height' - e.g. [[10,20,200,250]] selects a 200x250px rectangle starting 10 pixels from the left edge of the image and 20 pixels from the top edge of the image. The values for these arrays can be any integer from 0 to 10000. @param string $type The shape of the blur area. The options are rect (for a rectangle shape) or oval (for an oval shape). @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "partial_blur", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L709-L722
train
filestack/filestack-php
filestack/Filelink.php
Filelink.partialPixelate
public function partialPixelate($amount = 10, $blur = 4, $objects = [], $type = 'rect') { // call TransformationMixin function $this->setTransformUrl('partial_pixelate', ['a' => $amount, 'l' => $blur, 'o' => $objects, 't' => $type]); return $this; }
php
public function partialPixelate($amount = 10, $blur = 4, $objects = [], $type = 'rect') { // call TransformationMixin function $this->setTransformUrl('partial_pixelate', ['a' => $amount, 'l' => $blur, 'o' => $objects, 't' => $type]); return $this; }
[ "public", "function", "partialPixelate", "(", "$", "amount", "=", "10", ",", "$", "blur", "=", "4", ",", "$", "objects", "=", "[", "]", ",", "$", "type", "=", "'rect'", ")", "{", "// call TransformationMixin function", "$", "this", "->", "setTransformUrl",...
Set this Filelink's transform_url to include the partial_pixelate task @param int $amount Amount to pixelate the image. Range is 2 to 100 @param int $blur Amount to pixelate the image. Range is 0 to 20. @param array $objects Area(s) of the image to blur. This variable is an array of arrays. Each array input for this parameter defines a different section of the image and must have exactly 4 integers: 'x coordinate,y coordinate,width,height' - e.g. [[10,20,200,250]] selects a 200x250px rectangle starting 10 pixels from the left edge of the image and 20 pixels from the top edge of the image. The values for these arrays can be any integer from 0 to 10000. @param string $type The shape of the blur area. The options are rect (for rectangle shape) or oval (for oval shape). @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "partial_pixelate", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L746-L754
train
filestack/filestack-php
filestack/Filelink.php
Filelink.polaroid
public function polaroid($background = 'white', $color = 'snow', $rotate = 45) { $options = [ 'b' => $background, 'c' => $color, 'r' => $rotate ]; // call TransformationMixin function $this->setTransformUrl('polaroid', $options); return $this; }
php
public function polaroid($background = 'white', $color = 'snow', $rotate = 45) { $options = [ 'b' => $background, 'c' => $color, 'r' => $rotate ]; // call TransformationMixin function $this->setTransformUrl('polaroid', $options); return $this; }
[ "public", "function", "polaroid", "(", "$", "background", "=", "'white'", ",", "$", "color", "=", "'snow'", ",", "$", "rotate", "=", "45", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "background", ",", "'c'", "=>", "$", "color", ",", "'r'...
Set this Filelink's transform_url to include the polaroid task @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, ('red' or 'FF0000') @param string $color Sets the polaroid frame color. This can be a word or the hex value ('red' or 'FF0000') @param int $rotate Degree by which to rotate the image clockwise. Range is 0 to 359. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "polaroid", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L788-L800
train
filestack/filestack-php
filestack/Filelink.php
Filelink.resize
public function resize($width, $height, $fit = 'clip', $align = 'center') { $options = [ 'w' => $width, 'h' => $height, 'f' => $fit, 'a' => $align ]; // call TransformationMixin function $this->setTransformUrl('resize', $options); return $this; }
php
public function resize($width, $height, $fit = 'clip', $align = 'center') { $options = [ 'w' => $width, 'h' => $height, 'f' => $fit, 'a' => $align ]; // call TransformationMixin function $this->setTransformUrl('resize', $options); return $this; }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "fit", "=", "'clip'", ",", "$", "align", "=", "'center'", ")", "{", "$", "options", "=", "[", "'w'", "=>", "$", "width", ",", "'h'", "=>", "$", "height", ",", "'f'",...
Set this Filelink's transform_url to include the resize task @param int $width The width in pixels to resize the image to. The range is 1 to 10000. @param int $height The height in pixels to resize the image to. The range is 1 to 10000. @param string $fit clip, crop, scale, or max 'clip': Resizes the image to fit within the specified parameters without distorting, cropping, or changing the aspect ratio. 'crop': Resizes the image to fit the specified parameters exactly by removing any parts of the image that don't fit within the boundaries. 'scale': Resizes the image to fit the specified parameters exactly by scaling the image to the desired size. The aspect ratio of the image is not respected and the image can be distorted using this method. 'max': Resizes the image to fit within the parameters, but as opposed to 'clip' will not scale the image if the image is smaller than the output size. @param string $align Using align, you can choose the area of the image to focus on. Possible values: center, top, bottom, left, right, or faces You can also specify pairs e.g. align:[top,left]. Center cannot be used in pairs. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "resize", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L875-L888
train
filestack/filestack-php
filestack/Filelink.php
Filelink.roundedCorners
public function roundedCorners($background = 'white', $blur = 0.3, $radius = 10) { $options = [ 'b' => $background, 'l' => $blur, 'r' => $radius ]; // call TransformationMixin function $this->setTransformUrl('rounded_corners', $options); return $this; }
php
public function roundedCorners($background = 'white', $blur = 0.3, $radius = 10) { $options = [ 'b' => $background, 'l' => $blur, 'r' => $radius ]; // call TransformationMixin function $this->setTransformUrl('rounded_corners', $options); return $this; }
[ "public", "function", "roundedCorners", "(", "$", "background", "=", "'white'", ",", "$", "blur", "=", "0.3", ",", "$", "radius", "=", "10", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "background", ",", "'l'", "=>", "$", "blur", ",", "'r...
Set this Filelink's transform_url to include the rounded_corners task @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param float $blur Specify the amount of blur to apply to the rounded edges of the image. (0 - 20). @param int $radius The radius of the rounded corner effect on the image. (0-10000) @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "rounded_corners", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L905-L917
train
filestack/filestack-php
filestack/Filelink.php
Filelink.rotate
public function rotate($background = 'white', $deg = 0, $exif = false) { $options = [ 'b' => $background, 'd' => $deg, 'e' => $exif ? 'true' : 'false' ]; // call TransformationMixin function $this->setTransformUrl('rotate', $options); return $this; }
php
public function rotate($background = 'white', $deg = 0, $exif = false) { $options = [ 'b' => $background, 'd' => $deg, 'e' => $exif ? 'true' : 'false' ]; // call TransformationMixin function $this->setTransformUrl('rotate', $options); return $this; }
[ "public", "function", "rotate", "(", "$", "background", "=", "'white'", ",", "$", "deg", "=", "0", ",", "$", "exif", "=", "false", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "background", ",", "'d'", "=>", "$", "deg", ",", "'e'", "=>",...
Set this Filelink's transform_url to include the rotate task @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param int $deg The degree by which to rotate the image clockwise (0 to 359). Alternatively, you can set the degree to 'exif' and the image will be rotated based upon any exif metadata it may contain. @param bool $exif Sets the EXIF orientation of the image to EXIF orientation 1. The exif=false parameter takes an image and sets the exif orientation to the first of the eight EXIF orientations. The image will behave as though it is contained in an html img tag if displayed in application that supports EXIF orientations. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "rotate", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L942-L954
train
filestack/filestack-php
filestack/Filelink.php
Filelink.shadow
public function shadow($background = 'white', $blur = 4, $opacity = 60, $vector = [4,4]) { $options = [ 'b' => $background, 'l' => $blur, 'o' => $opacity, 'v' => $vector ]; // call TransformationMixin function $this->setTransformUrl('shadow', $options); return $this; }
php
public function shadow($background = 'white', $blur = 4, $opacity = 60, $vector = [4,4]) { $options = [ 'b' => $background, 'l' => $blur, 'o' => $opacity, 'v' => $vector ]; // call TransformationMixin function $this->setTransformUrl('shadow', $options); return $this; }
[ "public", "function", "shadow", "(", "$", "background", "=", "'white'", ",", "$", "blur", "=", "4", ",", "$", "opacity", "=", "60", ",", "$", "vector", "=", "[", "4", ",", "4", "]", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "backgro...
Set this Filelink's transform_url to include the shadow task @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param int $blur Sets the level of blur for the shadow effect. Value range is 0 to 20. @param int $opacity Sets the opacity level of the shadow effect. Value range is 0 to 100. @param array $vector Sets the vector of the shadow effect. The value must be an array of two integers in a range from -1000 to 1000. These are the X and Y parameters that determine the position of the shadow. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "shadow", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1012-L1026
train
filestack/filestack-php
filestack/Filelink.php
Filelink.tornEdges
public function tornEdges($background = 'white', $spread = [1,10]) { $options = [ 'b' => $background, 's' => $spread ]; // call TransformationMixin function $this->setTransformUrl('torn_edges', $options); return $this; }
php
public function tornEdges($background = 'white', $spread = [1,10]) { $options = [ 'b' => $background, 's' => $spread ]; // call TransformationMixin function $this->setTransformUrl('torn_edges', $options); return $this; }
[ "public", "function", "tornEdges", "(", "$", "background", "=", "'white'", ",", "$", "spread", "=", "[", "1", ",", "10", "]", ")", "{", "$", "options", "=", "[", "'b'", "=>", "$", "background", ",", "'s'", "=>", "$", "spread", "]", ";", "// call Tr...
Set this Filelink's transform_url to include the torn_edges task @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param array $spread Sets the spread of the tearing effect. The value must be an array of two integers in a range from 1 to 10000. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "torn_edges", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1042-L1053
train
filestack/filestack-php
filestack/Filelink.php
Filelink.upscale
public function upscale($noise = 'none', $style = 'photo', $upscale = true) { $options = [ 'n' => $noise, 's' => $style, 'u' => $upscale ? 'true' : 'false' ]; // call TransformationMixin function $this->setTransformUrl('upscale', $options); return $this; }
php
public function upscale($noise = 'none', $style = 'photo', $upscale = true) { $options = [ 'n' => $noise, 's' => $style, 'u' => $upscale ? 'true' : 'false' ]; // call TransformationMixin function $this->setTransformUrl('upscale', $options); return $this; }
[ "public", "function", "upscale", "(", "$", "noise", "=", "'none'", ",", "$", "style", "=", "'photo'", ",", "$", "upscale", "=", "true", ")", "{", "$", "options", "=", "[", "'n'", "=>", "$", "noise", ",", "'s'", "=>", "$", "style", ",", "'u'", "=>...
Set this Filelink's transform_url to include the upscale task @param string $noise none, low, medium or high Setting to reduce the level of noise in an image. This noise reduction is performed algorithmically and the aggressiveness of the noise reduction is determined by low, medium and high gradations. @param string $style artwork or photo If the image being upscaled is a drawing or piece of artwork with smooth lines, you will receive better results from the upscaling process if you also include the artwork style parameter. @param bool $upscale True will generate an image that is 2x the dimensions of the original. If false is passed as part of the task, then features like noise reduction can be used without changing the resolution of the image. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "upscale", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1080-L1092
train
filestack/filestack-php
filestack/Filelink.php
Filelink.vignette
public function vignette($amount = 20, $background = 'white', $blurmode = 'gaussian') { $options = [ 'a' => $amount, 'b' => $background, 'm' => $blurmode ]; // call TransformationMixin function $this->setTransformUrl('vignette', $options); return $this; }
php
public function vignette($amount = 20, $background = 'white', $blurmode = 'gaussian') { $options = [ 'a' => $amount, 'b' => $background, 'm' => $blurmode ]; // call TransformationMixin function $this->setTransformUrl('vignette', $options); return $this; }
[ "public", "function", "vignette", "(", "$", "amount", "=", "20", ",", "$", "background", "=", "'white'", ",", "$", "blurmode", "=", "'gaussian'", ")", "{", "$", "options", "=", "[", "'a'", "=>", "$", "amount", ",", "'b'", "=>", "$", "background", ","...
Set this Filelink's transform_url to include the vignette task @param int $amount The opacity of the vignette effect (0-100) @param string $background Sets the background color to display behind the image. This can be the word for a color, or the hex color code, e.g. ('red' or 'FF0000') @param string $blurmode linear or gaussian Controls the type of blur applied to the vignette - linear or gaussian. The vignette effect uses gaussian blur by default because it produces a more defined vignette around the image. Specifying linear is faster, but produces a less-defined blur effect, even at higher amounts. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "vignette", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1114-L1126
train
filestack/filestack-php
filestack/Filelink.php
Filelink.watermark
public function watermark($file_handle, $position = 'center', $size = 100) { $options = [ 'f' => $file_handle, 'p' => $position, 's' => $size ]; // call TransformationMixin function $this->setTransformUrl('watermark', $options); return $this; }
php
public function watermark($file_handle, $position = 'center', $size = 100) { $options = [ 'f' => $file_handle, 'p' => $position, 's' => $size ]; // call TransformationMixin function $this->setTransformUrl('watermark', $options); return $this; }
[ "public", "function", "watermark", "(", "$", "file_handle", ",", "$", "position", "=", "'center'", ",", "$", "size", "=", "100", ")", "{", "$", "options", "=", "[", "'f'", "=>", "$", "file_handle", ",", "'p'", "=>", "$", "position", ",", "'s'", "=>",...
Set this Filelink's transform_url to include the watermark task @param string $file_handle The Filestack handle of the image that you want to layer on top of another image as a watermark. @param string $position top, middle, bottom, left, center, or right The position of the overlayed image. These values can be paired as well like position: [top,right]. @param int $size The size of the overlayed image as a percentage of its original size. The value must be an integer between 1 and 500. @throws FilestackException if API call fails, e.g 404 file not found @return Filestack/Filelink
[ "Set", "this", "Filelink", "s", "transform_url", "to", "include", "the", "watermark", "task" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1146-L1158
train
filestack/filestack-php
filestack/Filelink.php
Filelink.getMetaData
public function getMetaData($fields = []) { // call CommonMixin function $result = $this->sendGetMetaData($this->url(), $fields, $this->security); foreach ($result as $key => $value) { $this->metadata[$key] = $value; } return $result; }
php
public function getMetaData($fields = []) { // call CommonMixin function $result = $this->sendGetMetaData($this->url(), $fields, $this->security); foreach ($result as $key => $value) { $this->metadata[$key] = $value; } return $result; }
[ "public", "function", "getMetaData", "(", "$", "fields", "=", "[", "]", ")", "{", "// call CommonMixin function", "$", "result", "=", "$", "this", "->", "sendGetMetaData", "(", "$", "this", "->", "url", "(", ")", ",", "$", "fields", ",", "$", "this", "...
Get metadata of filehandle @param array $fields optional, specific fields to retrieve. possible fields are: mimetype, filename, size, width, height, location, path, container, exif, uploaded (timestamp), writable, cloud, source_url @throws FilestackException if API call fails @return array
[ "Get", "metadata", "of", "filehandle" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1188-L1198
train
filestack/filestack-php
filestack/Filelink.php
Filelink.delete
public function delete() { // call CommonMixin function $result = $this->sendDelete($this->handle, $this->api_key, $this->security); return $result; }
php
public function delete() { // call CommonMixin function $result = $this->sendDelete($this->handle, $this->api_key, $this->security); return $result; }
[ "public", "function", "delete", "(", ")", "{", "// call CommonMixin function", "$", "result", "=", "$", "this", "->", "sendDelete", "(", "$", "this", "->", "handle", ",", "$", "this", "->", "api_key", ",", "$", "this", "->", "security", ")", ";", "return...
Delete this filelink from cloud storage @throws FilestackException if API call fails, e.g 404 file not found @return bool (true = delete success, false = failed)
[ "Delete", "this", "filelink", "from", "cloud", "storage" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1208-L1213
train
filestack/filestack-php
filestack/Filelink.php
Filelink.download
public function download($destination) { // call CommonMixin function $result = $this->sendDownload($this->url(), $destination, $this->security); return $result; }
php
public function download($destination) { // call CommonMixin function $result = $this->sendDownload($this->url(), $destination, $this->security); return $result; }
[ "public", "function", "download", "(", "$", "destination", ")", "{", "// call CommonMixin function", "$", "result", "=", "$", "this", "->", "sendDownload", "(", "$", "this", "->", "url", "(", ")", ",", "$", "destination", ",", "$", "this", "->", "security"...
Download filelink as a file, saving it to specified destination @param string $destination destination filepath to save to, can be folder name (defaults to stored filename) @throws FilestackException if API call fails @return bool (true = download success, false = failed)
[ "Download", "filelink", "as", "a", "file", "saving", "it", "to", "specified", "destination" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1225-L1230
train
filestack/filestack-php
filestack/Filelink.php
Filelink.overwrite
public function overwrite($filepath) { $result = $this->sendOverwrite($filepath, $this->handle, $this->api_key, $this->security); // update metadata $this->metadata['filename'] = $result->metadata['filename']; $this->metadata['mimetype'] = $result->metadata['mimetype']; $this->metadata['size'] = $result->metadata['size']; return true; }
php
public function overwrite($filepath) { $result = $this->sendOverwrite($filepath, $this->handle, $this->api_key, $this->security); // update metadata $this->metadata['filename'] = $result->metadata['filename']; $this->metadata['mimetype'] = $result->metadata['mimetype']; $this->metadata['size'] = $result->metadata['size']; return true; }
[ "public", "function", "overwrite", "(", "$", "filepath", ")", "{", "$", "result", "=", "$", "this", "->", "sendOverwrite", "(", "$", "filepath", ",", "$", "this", "->", "handle", ",", "$", "this", "->", "api_key", ",", "$", "this", "->", "security", ...
Overwrite this filelink in cloud storage @param string $filepath real path to file @throws FilestackException if API call fails, e.g 404 file not found @return boolean
[ "Overwrite", "this", "filelink", "in", "cloud", "storage" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1241-L1252
train
filestack/filestack-php
filestack/Filelink.php
Filelink.save
public function save($options = []) { $this->initTransformUrl(); $this->transform_url = $this->insertTransformStr($this->transform_url, 'store', $options); // call CommonMixin function $response = $this->sendRequest('GET', $this->transform_url); $filelink = $this->handleResponseCreateFilelink($response); return $filelink; }
php
public function save($options = []) { $this->initTransformUrl(); $this->transform_url = $this->insertTransformStr($this->transform_url, 'store', $options); // call CommonMixin function $response = $this->sendRequest('GET', $this->transform_url); $filelink = $this->handleResponseCreateFilelink($response); return $filelink; }
[ "public", "function", "save", "(", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "initTransformUrl", "(", ")", ";", "$", "this", "->", "transform_url", "=", "$", "this", "->", "insertTransformStr", "(", "$", "this", "->", "transform_url", ...
Save this transformed filelink in cloud storage @param array $options array of store options @throws FilestackException if API call fails, e.g 404 file not found @return Filestack\Filelink
[ "Save", "this", "transformed", "filelink", "in", "cloud", "storage" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1273-L1284
train
filestack/filestack-php
filestack/Filelink.php
Filelink.setTransformUrl
public function setTransformUrl($method, $options = []) { $this->initTransformUrl(); $this->transform_url = $this->insertTransformStr($this->transform_url, $method, $options); }
php
public function setTransformUrl($method, $options = []) { $this->initTransformUrl(); $this->transform_url = $this->insertTransformStr($this->transform_url, $method, $options); }
[ "public", "function", "setTransformUrl", "(", "$", "method", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "initTransformUrl", "(", ")", ";", "$", "this", "->", "transform_url", "=", "$", "this", "->", "insertTransformStr", "(", "$", ...
Append or Create a task to the transformation url for this filelink @param array $options task options, e.g. ['b' => '00FF00', 'd' => '45'] @throws FilestackException if API call fails, e.g 404 file not found @return void
[ "Append", "or", "Create", "a", "task", "to", "the", "transformation", "url", "for", "this", "filelink" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1295-L1300
train
filestack/filestack-php
filestack/Filelink.php
Filelink.transform
public function transform($transform_tasks) { // call TransformationMixin $result = $this->sendTransform($this->handle, $transform_tasks, $this->security); return $result; }
php
public function transform($transform_tasks) { // call TransformationMixin $result = $this->sendTransform($this->handle, $transform_tasks, $this->security); return $result; }
[ "public", "function", "transform", "(", "$", "transform_tasks", ")", "{", "// call TransformationMixin", "$", "result", "=", "$", "this", "->", "sendTransform", "(", "$", "this", "->", "handle", ",", "$", "transform_tasks", ",", "$", "this", "->", "security", ...
Applied array of transformation tasks to this file link. @param array $transform_tasks array of transformation tasks and optional attributes per task @throws FilestackException if API call fails, e.g 404 file not found @return Filestack\Filelink or contents
[ "Applied", "array", "of", "transformation", "tasks", "to", "this", "file", "link", "." ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1338-L1345
train
filestack/filestack-php
filestack/Filelink.php
Filelink.initTransformUrl
protected function initTransformUrl() { if (!$this->transform_url) { // security in a different format for transformations $security_str = $this->security ? sprintf('/security=policy:%s,signature:%s', $this->security->policy, $this->security->signature ) : ''; $this->transform_url = sprintf(FilestackConfig::CDN_URL . '%s/%s', $security_str, $this->handle); } }
php
protected function initTransformUrl() { if (!$this->transform_url) { // security in a different format for transformations $security_str = $this->security ? sprintf('/security=policy:%s,signature:%s', $this->security->policy, $this->security->signature ) : ''; $this->transform_url = sprintf(FilestackConfig::CDN_URL . '%s/%s', $security_str, $this->handle); } }
[ "protected", "function", "initTransformUrl", "(", ")", "{", "if", "(", "!", "$", "this", "->", "transform_url", ")", "{", "// security in a different format for transformations", "$", "security_str", "=", "$", "this", "->", "security", "?", "sprintf", "(", "'/secu...
Initialize transform url if it doesnt exist
[ "Initialize", "transform", "url", "if", "it", "doesnt", "exist" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1390-L1404
train
filestack/filestack-php
filestack/mixins/CommonMixin.php
CommonMixin.isUrl
public function isUrl($url) { $path = parse_url($url, PHP_URL_PATH); $encoded_path = array_map('urlencode', explode('/', $path)); $url = str_replace($path, implode('/', $encoded_path), $url); return filter_var($url, FILTER_VALIDATE_URL); }
php
public function isUrl($url) { $path = parse_url($url, PHP_URL_PATH); $encoded_path = array_map('urlencode', explode('/', $path)); $url = str_replace($path, implode('/', $encoded_path), $url); return filter_var($url, FILTER_VALIDATE_URL); }
[ "public", "function", "isUrl", "(", "$", "url", ")", "{", "$", "path", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ";", "$", "encoded_path", "=", "array_map", "(", "'urlencode'", ",", "explode", "(", "'/'", ",", "$", "path", ")", ")"...
Check if a string is a valid url. @param string $url url string to check @return bool
[ "Check", "if", "a", "string", "is", "a", "valid", "url", "." ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L33-L40
train
filestack/filestack-php
filestack/mixins/CommonMixin.php
CommonMixin.sendDelete
public function sendDelete($handle, $api_key, $security) { $url = sprintf('%s/file/%s?key=%s', FilestackConfig::API_URL, $handle, $api_key); if ($security) { $url = $security->signUrl($url); } $response = $this->sendRequest('DELETE', $url); $status_code = $response->getStatusCode(); // handle response if ($status_code !== 200) { throw new FilestackException($response->getBody(), $status_code); } return true; }
php
public function sendDelete($handle, $api_key, $security) { $url = sprintf('%s/file/%s?key=%s', FilestackConfig::API_URL, $handle, $api_key); if ($security) { $url = $security->signUrl($url); } $response = $this->sendRequest('DELETE', $url); $status_code = $response->getStatusCode(); // handle response if ($status_code !== 200) { throw new FilestackException($response->getBody(), $status_code); } return true; }
[ "public", "function", "sendDelete", "(", "$", "handle", ",", "$", "api_key", ",", "$", "security", ")", "{", "$", "url", "=", "sprintf", "(", "'%s/file/%s?key=%s'", ",", "FilestackConfig", "::", "API_URL", ",", "$", "handle", ",", "$", "api_key", ")", ";...
Delete a file from cloud storage @param string $handle Filestack file handle to delete @param string $api_key Filestack API Key @param FilestackSecurity $security Filestack security object is required for this call @throws FilestackException if API call fails, e.g 404 file not found @return bool (true = delete success, false = failed)
[ "Delete", "a", "file", "from", "cloud", "storage" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L67-L85
train
filestack/filestack-php
filestack/mixins/CommonMixin.php
CommonMixin.sendDownload
protected function sendDownload($url, $destination, $security = null) { if (is_dir($destination)) { // destination is a folder $json = $this->sendGetMetaData($url, ["filename"], $security); $remote_filename = $json['filename']; $destination .= $remote_filename; } // sign url if security is passed in if ($security) { $url = $security->signUrl($url); } # send request $options = ['sink' => $destination]; $url .= '&dl=true'; $response = $this->sendRequest('GET', $url, $options); $status_code = $response->getStatusCode(); // handle response if ($status_code !== 200) { throw new FilestackException($response->getBody(), $status_code); } return true; }
php
protected function sendDownload($url, $destination, $security = null) { if (is_dir($destination)) { // destination is a folder $json = $this->sendGetMetaData($url, ["filename"], $security); $remote_filename = $json['filename']; $destination .= $remote_filename; } // sign url if security is passed in if ($security) { $url = $security->signUrl($url); } # send request $options = ['sink' => $destination]; $url .= '&dl=true'; $response = $this->sendRequest('GET', $url, $options); $status_code = $response->getStatusCode(); // handle response if ($status_code !== 200) { throw new FilestackException($response->getBody(), $status_code); } return true; }
[ "protected", "function", "sendDownload", "(", "$", "url", ",", "$", "destination", ",", "$", "security", "=", "null", ")", "{", "if", "(", "is_dir", "(", "$", "destination", ")", ")", "{", "// destination is a folder", "$", "json", "=", "$", "this", "->"...
Download a file to specified destination given a url @param string $url Filestack file url @param string $destination destination filepath to save to, can be a directory name @param FilestackSecurity $security Filestack security object if security settings is turned on @throws FilestackException if API call fails, e.g 404 file not found @return bool (true = download success, false = failed)
[ "Download", "a", "file", "to", "specified", "destination", "given", "a", "url" ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L100-L127
train
filestack/filestack-php
filestack/mixins/CommonMixin.php
CommonMixin.sendGetContent
protected function sendGetContent($url, $security = null) { // sign url if security is passed in if ($security) { $url = $security->signUrl($url); } $response = $this->sendRequest('GET', $url); $status_code = $response->getStatusCode(); // handle response if ($status_code !== 200) { throw new FilestackException($response->getBody(), $status_code); } $content = $response->getBody()->getContents(); return $content; }
php
protected function sendGetContent($url, $security = null) { // sign url if security is passed in if ($security) { $url = $security->signUrl($url); } $response = $this->sendRequest('GET', $url); $status_code = $response->getStatusCode(); // handle response if ($status_code !== 200) { throw new FilestackException($response->getBody(), $status_code); } $content = $response->getBody()->getContents(); return $content; }
[ "protected", "function", "sendGetContent", "(", "$", "url", ",", "$", "security", "=", "null", ")", "{", "// sign url if security is passed in", "if", "(", "$", "security", ")", "{", "$", "url", "=", "$", "security", "->", "signUrl", "(", "$", "url", ")", ...
Get the content of a file. @param string $url Filestack file url @param FilestackSecurity $security Filestack security object if security settings is turned on @throws FilestackException if API call fails, e.g 404 file not found @return string (file content)
[ "Get", "the", "content", "of", "a", "file", "." ]
5396650b246969fec929fdd2c6ab908adb5b28e2
https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L140-L158
train