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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
gianarb/GaGooGl
src/GaGooGl/Http/Request.php
Request.getLongLinkbyShort
public function getLongLinkbyShort($shortLink) { $this->client->setMethod('GET'); $this->client->setUri("https://www.googleapis.com/urlshortener/v1/url?shortUrl={$shortLink}"); $contentJson = $this->client->send()->getContent(); $responseArray = json_decode($contentJson, true); if (!empty($responseArray['error'])) { $response = new Response(); return $response->setError($responseArray['error']['errors']); } else { $response = new Response(); $response->setId($responseArray['id']) ->setKind($responseArray['kind']) ->setLongUrl($responseArray['longUrl']) ->setStatus($responseArray['status']); return $response; } }
php
public function getLongLinkbyShort($shortLink) { $this->client->setMethod('GET'); $this->client->setUri("https://www.googleapis.com/urlshortener/v1/url?shortUrl={$shortLink}"); $contentJson = $this->client->send()->getContent(); $responseArray = json_decode($contentJson, true); if (!empty($responseArray['error'])) { $response = new Response(); return $response->setError($responseArray['error']['errors']); } else { $response = new Response(); $response->setId($responseArray['id']) ->setKind($responseArray['kind']) ->setLongUrl($responseArray['longUrl']) ->setStatus($responseArray['status']); return $response; } }
[ "public", "function", "getLongLinkbyShort", "(", "$", "shortLink", ")", "{", "$", "this", "->", "client", "->", "setMethod", "(", "'GET'", ")", ";", "$", "this", "->", "client", "->", "setUri", "(", "\"https://www.googleapis.com/urlshortener/v1/url?shortUrl={$shortLink}\"", ")", ";", "$", "contentJson", "=", "$", "this", "->", "client", "->", "send", "(", ")", "->", "getContent", "(", ")", ";", "$", "responseArray", "=", "json_decode", "(", "$", "contentJson", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "responseArray", "[", "'error'", "]", ")", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "return", "$", "response", "->", "setError", "(", "$", "responseArray", "[", "'error'", "]", "[", "'errors'", "]", ")", ";", "}", "else", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "setId", "(", "$", "responseArray", "[", "'id'", "]", ")", "->", "setKind", "(", "$", "responseArray", "[", "'kind'", "]", ")", "->", "setLongUrl", "(", "$", "responseArray", "[", "'longUrl'", "]", ")", "->", "setStatus", "(", "$", "responseArray", "[", "'status'", "]", ")", ";", "return", "$", "response", ";", "}", "}" ]
Return Long url bu Short url @param $shortLink @return Response
[ "Return", "Long", "url", "bu", "Short", "url" ]
d7ebd3a74edb44a65d32b1b19d54eda55f638eaa
https://github.com/gianarb/GaGooGl/blob/d7ebd3a74edb44a65d32b1b19d54eda55f638eaa/src/GaGooGl/Http/Request.php#L55-L72
train
geoffroy-aubry/Helpers
src/GAubry/Helpers/Counter.php
Counter.start
public function start($iMaxDuration, $iHeartbeat) { $fNow = microtime(true); $this->aData = [ 'ts_limit' => $fNow + $iMaxDuration, 'lap_duration' => $iHeartbeat, 'lap_start' => $fNow, 'lap_end' => $fNow + $iHeartbeat, 'lap_nb_events' => 0, 'total_nb_events' => 0 ]; return $this; }
php
public function start($iMaxDuration, $iHeartbeat) { $fNow = microtime(true); $this->aData = [ 'ts_limit' => $fNow + $iMaxDuration, 'lap_duration' => $iHeartbeat, 'lap_start' => $fNow, 'lap_end' => $fNow + $iHeartbeat, 'lap_nb_events' => 0, 'total_nb_events' => 0 ]; return $this; }
[ "public", "function", "start", "(", "$", "iMaxDuration", ",", "$", "iHeartbeat", ")", "{", "$", "fNow", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "aData", "=", "[", "'ts_limit'", "=>", "$", "fNow", "+", "$", "iMaxDuration", ",", "'lap_duration'", "=>", "$", "iHeartbeat", ",", "'lap_start'", "=>", "$", "fNow", ",", "'lap_end'", "=>", "$", "fNow", "+", "$", "iHeartbeat", ",", "'lap_nb_events'", "=>", "0", ",", "'total_nb_events'", "=>", "0", "]", ";", "return", "$", "this", ";", "}" ]
Init data structure. @param int $iMaxDuration Max number of seconds waiting/processing events. @param int $iHeartbeat Approximate desired delay in seconds between 2 stats diplay. @return Counter $this @see $aData
[ "Init", "data", "structure", "." ]
09e787e554158d7c2233a27107d2949824cd5602
https://github.com/geoffroy-aubry/Helpers/blob/09e787e554158d7c2233a27107d2949824cd5602/src/GAubry/Helpers/Counter.php#L76-L88
train
geoffroy-aubry/Helpers
src/GAubry/Helpers/Counter.php
Counter.doTic
public function doTic() { $aData = &$this->aData; $fNow = microtime(true); if ($fNow >= $aData['lap_end'] || $this->isTimeLimitExceeded()) { $iNbEventsPerSec = round($aData['lap_nb_events'] / ($fNow - $aData['lap_start'])); $sMsg = sprintf( $this->sFormat, $iNbEventsPerSec, $aData['lap_nb_events'], $aData['total_nb_events'] ); $aData['lap_start'] = $fNow; $aData['lap_end'] += $aData['lap_duration'] * ceil(($fNow - $aData['lap_end']) / $aData['lap_duration']); $aData['lap_nb_events'] = 0; } else { $sMsg = ''; } return $sMsg; }
php
public function doTic() { $aData = &$this->aData; $fNow = microtime(true); if ($fNow >= $aData['lap_end'] || $this->isTimeLimitExceeded()) { $iNbEventsPerSec = round($aData['lap_nb_events'] / ($fNow - $aData['lap_start'])); $sMsg = sprintf( $this->sFormat, $iNbEventsPerSec, $aData['lap_nb_events'], $aData['total_nb_events'] ); $aData['lap_start'] = $fNow; $aData['lap_end'] += $aData['lap_duration'] * ceil(($fNow - $aData['lap_end']) / $aData['lap_duration']); $aData['lap_nb_events'] = 0; } else { $sMsg = ''; } return $sMsg; }
[ "public", "function", "doTic", "(", ")", "{", "$", "aData", "=", "&", "$", "this", "->", "aData", ";", "$", "fNow", "=", "microtime", "(", "true", ")", ";", "if", "(", "$", "fNow", ">=", "$", "aData", "[", "'lap_end'", "]", "||", "$", "this", "->", "isTimeLimitExceeded", "(", ")", ")", "{", "$", "iNbEventsPerSec", "=", "round", "(", "$", "aData", "[", "'lap_nb_events'", "]", "/", "(", "$", "fNow", "-", "$", "aData", "[", "'lap_start'", "]", ")", ")", ";", "$", "sMsg", "=", "sprintf", "(", "$", "this", "->", "sFormat", ",", "$", "iNbEventsPerSec", ",", "$", "aData", "[", "'lap_nb_events'", "]", ",", "$", "aData", "[", "'total_nb_events'", "]", ")", ";", "$", "aData", "[", "'lap_start'", "]", "=", "$", "fNow", ";", "$", "aData", "[", "'lap_end'", "]", "+=", "$", "aData", "[", "'lap_duration'", "]", "*", "ceil", "(", "(", "$", "fNow", "-", "$", "aData", "[", "'lap_end'", "]", ")", "/", "$", "aData", "[", "'lap_duration'", "]", ")", ";", "$", "aData", "[", "'lap_nb_events'", "]", "=", "0", ";", "}", "else", "{", "$", "sMsg", "=", "''", ";", "}", "return", "$", "sMsg", ";", "}" ]
Display stats about number of processed events since last display.
[ "Display", "stats", "about", "number", "of", "processed", "events", "since", "last", "display", "." ]
09e787e554158d7c2233a27107d2949824cd5602
https://github.com/geoffroy-aubry/Helpers/blob/09e787e554158d7c2233a27107d2949824cd5602/src/GAubry/Helpers/Counter.php#L112-L133
train
WellCommerce/CartBundle
Manager/Front/CartManager.php
CartManager.getCart
protected function getCart(ShopInterface $shop, ClientInterface $client = null, $sessionId, $currency) { $cart = $this->repository->findCart($client, $sessionId, $shop); if (null === $cart) { $cart = $this->createCart($shop, $client); } else { $this->updateCart($cart, $client, $currency); } return $cart; }
php
protected function getCart(ShopInterface $shop, ClientInterface $client = null, $sessionId, $currency) { $cart = $this->repository->findCart($client, $sessionId, $shop); if (null === $cart) { $cart = $this->createCart($shop, $client); } else { $this->updateCart($cart, $client, $currency); } return $cart; }
[ "protected", "function", "getCart", "(", "ShopInterface", "$", "shop", ",", "ClientInterface", "$", "client", "=", "null", ",", "$", "sessionId", ",", "$", "currency", ")", "{", "$", "cart", "=", "$", "this", "->", "repository", "->", "findCart", "(", "$", "client", ",", "$", "sessionId", ",", "$", "shop", ")", ";", "if", "(", "null", "===", "$", "cart", ")", "{", "$", "cart", "=", "$", "this", "->", "createCart", "(", "$", "shop", ",", "$", "client", ")", ";", "}", "else", "{", "$", "this", "->", "updateCart", "(", "$", "cart", ",", "$", "client", ",", "$", "currency", ")", ";", "}", "return", "$", "cart", ";", "}" ]
Returns an existent cart or creates a new one if needed @param ShopInterface $shop @param ClientInterface|null $client @param string $sessionId @param string $currency @return CartInterface
[ "Returns", "an", "existent", "cart", "or", "creates", "a", "new", "one", "if", "needed" ]
77c1e12b36bde008dca61260481b21135e339396
https://github.com/WellCommerce/CartBundle/blob/77c1e12b36bde008dca61260481b21135e339396/Manager/Front/CartManager.php#L137-L148
train
WellCommerce/CartBundle
Manager/Front/CartManager.php
CartManager.createCart
protected function createCart(ShopInterface $shop, ClientInterface $client = null) { $cart = $this->initResource(); $cart->setShop($shop); $cart->setClient($client); $this->createResource($cart); return $cart; }
php
protected function createCart(ShopInterface $shop, ClientInterface $client = null) { $cart = $this->initResource(); $cart->setShop($shop); $cart->setClient($client); $this->createResource($cart); return $cart; }
[ "protected", "function", "createCart", "(", "ShopInterface", "$", "shop", ",", "ClientInterface", "$", "client", "=", "null", ")", "{", "$", "cart", "=", "$", "this", "->", "initResource", "(", ")", ";", "$", "cart", "->", "setShop", "(", "$", "shop", ")", ";", "$", "cart", "->", "setClient", "(", "$", "client", ")", ";", "$", "this", "->", "createResource", "(", "$", "cart", ")", ";", "return", "$", "cart", ";", "}" ]
Creates cart using factory @param ShopInterface $shop @param ClientInterface|null $client @return CartInterface
[ "Creates", "cart", "using", "factory" ]
77c1e12b36bde008dca61260481b21135e339396
https://github.com/WellCommerce/CartBundle/blob/77c1e12b36bde008dca61260481b21135e339396/Manager/Front/CartManager.php#L184-L193
train
libreworks/caridea-auth
src/Adapter/Pdo.php
Pdo.execute
protected function execute(string $username, ServerRequestInterface $request): \PDOStatement { $stmt = $this->pdo->prepare($this->getSql()); $stmt->execute([$username]); return $stmt; }
php
protected function execute(string $username, ServerRequestInterface $request): \PDOStatement { $stmt = $this->pdo->prepare($this->getSql()); $stmt->execute([$username]); return $stmt; }
[ "protected", "function", "execute", "(", "string", "$", "username", ",", "ServerRequestInterface", "$", "request", ")", ":", "\\", "PDOStatement", "{", "$", "stmt", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "this", "->", "getSql", "(", ")", ")", ";", "$", "stmt", "->", "execute", "(", "[", "$", "username", "]", ")", ";", "return", "$", "stmt", ";", "}" ]
Queries the database table. Override this method if you want to bind additonal values to the SQL query. @param string $username The username to use for parameter binding @param ServerRequestInterface $request The Server Request message (to use for additional parameter binding)
[ "Queries", "the", "database", "table", "." ]
1bf965c57716942b18ca3204629f6bda99cf876a
https://github.com/libreworks/caridea-auth/blob/1bf965c57716942b18ca3204629f6bda99cf876a/src/Adapter/Pdo.php#L115-L120
train
libreworks/caridea-auth
src/Adapter/Pdo.php
Pdo.fetchResult
protected function fetchResult(array $results, string $username): array { if (count($results) > 1) { throw new \Caridea\Auth\Exception\UsernameAmbiguous($username); } elseif (count($results) == 0) { throw new \Caridea\Auth\Exception\UsernameNotFound($username); } return current($results); }
php
protected function fetchResult(array $results, string $username): array { if (count($results) > 1) { throw new \Caridea\Auth\Exception\UsernameAmbiguous($username); } elseif (count($results) == 0) { throw new \Caridea\Auth\Exception\UsernameNotFound($username); } return current($results); }
[ "protected", "function", "fetchResult", "(", "array", "$", "results", ",", "string", "$", "username", ")", ":", "array", "{", "if", "(", "count", "(", "$", "results", ")", ">", "1", ")", "{", "throw", "new", "\\", "Caridea", "\\", "Auth", "\\", "Exception", "\\", "UsernameAmbiguous", "(", "$", "username", ")", ";", "}", "elseif", "(", "count", "(", "$", "results", ")", "==", "0", ")", "{", "throw", "new", "\\", "Caridea", "\\", "Auth", "\\", "Exception", "\\", "UsernameNotFound", "(", "$", "username", ")", ";", "}", "return", "current", "(", "$", "results", ")", ";", "}" ]
Fetches a single result from the database resultset. @param array $results The results as returned from `fetchAll` @param string $username The attempted username (for Exception purposes) @return array A single database result @throws \Caridea\Auth\Exception\UsernameAmbiguous If there is more than 1 result @throws \Caridea\Auth\Exception\UsernameNotFound If there are 0 results
[ "Fetches", "a", "single", "result", "from", "the", "database", "resultset", "." ]
1bf965c57716942b18ca3204629f6bda99cf876a
https://github.com/libreworks/caridea-auth/blob/1bf965c57716942b18ca3204629f6bda99cf876a/src/Adapter/Pdo.php#L145-L153
train
bkstg/schedule-bundle
Search/EventSubscriber/FilterCollectionSubscriber.php
FilterCollectionSubscriber.addEventFilter
public function addEventFilter(FilterCollectionEvent $event): void { $now = new \DateTime(); $qb = $event->getQueryBuilder(); $query = $qb->query()->bool() ->addMust($qb->query()->term(['_index' => 'event'])) ->addMust($qb->query()->term(['active' => true])) ->addMust($qb->query()->terms('groups.id', $event->getGroupIds())) ->addMustNot($qb->query()->exists('schedule')) ; $event->addFilter($query); }
php
public function addEventFilter(FilterCollectionEvent $event): void { $now = new \DateTime(); $qb = $event->getQueryBuilder(); $query = $qb->query()->bool() ->addMust($qb->query()->term(['_index' => 'event'])) ->addMust($qb->query()->term(['active' => true])) ->addMust($qb->query()->terms('groups.id', $event->getGroupIds())) ->addMustNot($qb->query()->exists('schedule')) ; $event->addFilter($query); }
[ "public", "function", "addEventFilter", "(", "FilterCollectionEvent", "$", "event", ")", ":", "void", "{", "$", "now", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "qb", "=", "$", "event", "->", "getQueryBuilder", "(", ")", ";", "$", "query", "=", "$", "qb", "->", "query", "(", ")", "->", "bool", "(", ")", "->", "addMust", "(", "$", "qb", "->", "query", "(", ")", "->", "term", "(", "[", "'_index'", "=>", "'event'", "]", ")", ")", "->", "addMust", "(", "$", "qb", "->", "query", "(", ")", "->", "term", "(", "[", "'active'", "=>", "true", "]", ")", ")", "->", "addMust", "(", "$", "qb", "->", "query", "(", ")", "->", "terms", "(", "'groups.id'", ",", "$", "event", "->", "getGroupIds", "(", ")", ")", ")", "->", "addMustNot", "(", "$", "qb", "->", "query", "(", ")", "->", "exists", "(", "'schedule'", ")", ")", ";", "$", "event", "->", "addFilter", "(", "$", "query", ")", ";", "}" ]
Add the event filter to search. @param FilterCollectionEvent $event The filter collection event. @return void
[ "Add", "the", "event", "filter", "to", "search", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Search/EventSubscriber/FilterCollectionSubscriber.php#L41-L52
train
bkstg/schedule-bundle
Search/EventSubscriber/FilterCollectionSubscriber.php
FilterCollectionSubscriber.addScheduleFilter
public function addScheduleFilter(FilterCollectionEvent $event): void { $now = new \DateTime(); $qb = $event->getQueryBuilder(); $query = $qb->query()->bool() ->addMust($qb->query()->term(['_index' => 'schedule'])) ->addMust($qb->query()->term(['active' => true])) ->addMust($qb->query()->terms('groups.id', $event->getGroupIds())) ; $event->addFilter($query); }
php
public function addScheduleFilter(FilterCollectionEvent $event): void { $now = new \DateTime(); $qb = $event->getQueryBuilder(); $query = $qb->query()->bool() ->addMust($qb->query()->term(['_index' => 'schedule'])) ->addMust($qb->query()->term(['active' => true])) ->addMust($qb->query()->terms('groups.id', $event->getGroupIds())) ; $event->addFilter($query); }
[ "public", "function", "addScheduleFilter", "(", "FilterCollectionEvent", "$", "event", ")", ":", "void", "{", "$", "now", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "qb", "=", "$", "event", "->", "getQueryBuilder", "(", ")", ";", "$", "query", "=", "$", "qb", "->", "query", "(", ")", "->", "bool", "(", ")", "->", "addMust", "(", "$", "qb", "->", "query", "(", ")", "->", "term", "(", "[", "'_index'", "=>", "'schedule'", "]", ")", ")", "->", "addMust", "(", "$", "qb", "->", "query", "(", ")", "->", "term", "(", "[", "'active'", "=>", "true", "]", ")", ")", "->", "addMust", "(", "$", "qb", "->", "query", "(", ")", "->", "terms", "(", "'groups.id'", ",", "$", "event", "->", "getGroupIds", "(", ")", ")", ")", ";", "$", "event", "->", "addFilter", "(", "$", "query", ")", ";", "}" ]
Add the schedule filter to search. @param FilterCollectionEvent $event The filter collection event. @return void
[ "Add", "the", "schedule", "filter", "to", "search", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Search/EventSubscriber/FilterCollectionSubscriber.php#L61-L71
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.fetchTree
public function fetchTree($rootId=null, $depth=null) { $wrappers = $this->fetchTreeAsArray($rootId, $depth); return (!is_array($wrappers) || empty($wrappers)) ? null : $wrappers[0]; }
php
public function fetchTree($rootId=null, $depth=null) { $wrappers = $this->fetchTreeAsArray($rootId, $depth); return (!is_array($wrappers) || empty($wrappers)) ? null : $wrappers[0]; }
[ "public", "function", "fetchTree", "(", "$", "rootId", "=", "null", ",", "$", "depth", "=", "null", ")", "{", "$", "wrappers", "=", "$", "this", "->", "fetchTreeAsArray", "(", "$", "rootId", ",", "$", "depth", ")", ";", "return", "(", "!", "is_array", "(", "$", "wrappers", ")", "||", "empty", "(", "$", "wrappers", ")", ")", "?", "null", ":", "$", "wrappers", "[", "0", "]", ";", "}" ]
Fetches the complete tree, returning the root node of the tree @param mixed $rootId the root id of the tree (or null if model doesn't support multiple trees @param int $depth the depth to retrieve or null for unlimited @return NodeWrapper $root
[ "Fetches", "the", "complete", "tree", "returning", "the", "root", "node", "of", "the", "tree" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L59-L64
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.fetchTreeAsArray
public function fetchTreeAsArray($rootId=null, $depth=null) { $config = $this->getConfiguration(); $lftField = $config->getLeftFieldName(); $rgtField = $config->getRightFieldName(); $rootField = $config->getRootFieldName(); $hasManyRoots = $config->hasManyRoots(); if($rootId === null && $rootField !== null) { throw new \InvalidArgumentException('Must provide root id'); } if($depth === 0) { return array(); } $qb = $config->getBaseQueryBuilder(); $alias = $config->getQueryBuilderAlias(); $qb->andWhere("$alias.$lftField >= :lowerbound") ->setParameter('lowerbound', 1) ->orderBy("$alias.$lftField", "ASC"); if($hasManyRoots) { $qb->andWhere("$alias.$rootField = :rootid") ->setParameter('rootid', $rootId); } $q = $qb->getQuery(); if ($this->config->isQueryHintSet()){ $q = $this->addHintToQuery($q); } $nodes = $q->execute(); if(empty($nodes)) { return array(); } // TODO: Filter depth using a cross join instead of this if($depth !== null) { $nodes = $this->filterNodeDepth($nodes, $depth); } $wrappers = array(); foreach($nodes as $node) { $wrappers[] = $this->wrapNode($node); } $this->buildTree($wrappers); return $wrappers; }
php
public function fetchTreeAsArray($rootId=null, $depth=null) { $config = $this->getConfiguration(); $lftField = $config->getLeftFieldName(); $rgtField = $config->getRightFieldName(); $rootField = $config->getRootFieldName(); $hasManyRoots = $config->hasManyRoots(); if($rootId === null && $rootField !== null) { throw new \InvalidArgumentException('Must provide root id'); } if($depth === 0) { return array(); } $qb = $config->getBaseQueryBuilder(); $alias = $config->getQueryBuilderAlias(); $qb->andWhere("$alias.$lftField >= :lowerbound") ->setParameter('lowerbound', 1) ->orderBy("$alias.$lftField", "ASC"); if($hasManyRoots) { $qb->andWhere("$alias.$rootField = :rootid") ->setParameter('rootid', $rootId); } $q = $qb->getQuery(); if ($this->config->isQueryHintSet()){ $q = $this->addHintToQuery($q); } $nodes = $q->execute(); if(empty($nodes)) { return array(); } // TODO: Filter depth using a cross join instead of this if($depth !== null) { $nodes = $this->filterNodeDepth($nodes, $depth); } $wrappers = array(); foreach($nodes as $node) { $wrappers[] = $this->wrapNode($node); } $this->buildTree($wrappers); return $wrappers; }
[ "public", "function", "fetchTreeAsArray", "(", "$", "rootId", "=", "null", ",", "$", "depth", "=", "null", ")", "{", "$", "config", "=", "$", "this", "->", "getConfiguration", "(", ")", ";", "$", "lftField", "=", "$", "config", "->", "getLeftFieldName", "(", ")", ";", "$", "rgtField", "=", "$", "config", "->", "getRightFieldName", "(", ")", ";", "$", "rootField", "=", "$", "config", "->", "getRootFieldName", "(", ")", ";", "$", "hasManyRoots", "=", "$", "config", "->", "hasManyRoots", "(", ")", ";", "if", "(", "$", "rootId", "===", "null", "&&", "$", "rootField", "!==", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Must provide root id'", ")", ";", "}", "if", "(", "$", "depth", "===", "0", ")", "{", "return", "array", "(", ")", ";", "}", "$", "qb", "=", "$", "config", "->", "getBaseQueryBuilder", "(", ")", ";", "$", "alias", "=", "$", "config", "->", "getQueryBuilderAlias", "(", ")", ";", "$", "qb", "->", "andWhere", "(", "\"$alias.$lftField >= :lowerbound\"", ")", "->", "setParameter", "(", "'lowerbound'", ",", "1", ")", "->", "orderBy", "(", "\"$alias.$lftField\"", ",", "\"ASC\"", ")", ";", "if", "(", "$", "hasManyRoots", ")", "{", "$", "qb", "->", "andWhere", "(", "\"$alias.$rootField = :rootid\"", ")", "->", "setParameter", "(", "'rootid'", ",", "$", "rootId", ")", ";", "}", "$", "q", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "if", "(", "$", "this", "->", "config", "->", "isQueryHintSet", "(", ")", ")", "{", "$", "q", "=", "$", "this", "->", "addHintToQuery", "(", "$", "q", ")", ";", "}", "$", "nodes", "=", "$", "q", "->", "execute", "(", ")", ";", "if", "(", "empty", "(", "$", "nodes", ")", ")", "{", "return", "array", "(", ")", ";", "}", "// TODO: Filter depth using a cross join instead of this", "if", "(", "$", "depth", "!==", "null", ")", "{", "$", "nodes", "=", "$", "this", "->", "filterNodeDepth", "(", "$", "nodes", ",", "$", "depth", ")", ";", "}", "$", "wrappers", "=", "array", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "wrappers", "[", "]", "=", "$", "this", "->", "wrapNode", "(", "$", "node", ")", ";", "}", "$", "this", "->", "buildTree", "(", "$", "wrappers", ")", ";", "return", "$", "wrappers", ";", "}" ]
Fetches the complete tree, returning a flat array of node wrappers with parent, children, ancestors and descendants pre-populated. @param mixed $rootId the root id of the tree (or null if model doesn't support multiple trees @param int $depth the depth to retrieve or null for unlimited @return array
[ "Fetches", "the", "complete", "tree", "returning", "a", "flat", "array", "of", "node", "wrappers", "with", "parent", "children", "ancestors", "and", "descendants", "pre", "-", "populated", "." ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L77-L134
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.fetchBranch
public function fetchBranch($pk, $depth=null) { $wrappers = $this->fetchBranchAsArray($pk, $depth); return (!is_array($wrappers) || empty($wrappers)) ? null : $wrappers[0]; }
php
public function fetchBranch($pk, $depth=null) { $wrappers = $this->fetchBranchAsArray($pk, $depth); return (!is_array($wrappers) || empty($wrappers)) ? null : $wrappers[0]; }
[ "public", "function", "fetchBranch", "(", "$", "pk", ",", "$", "depth", "=", "null", ")", "{", "$", "wrappers", "=", "$", "this", "->", "fetchBranchAsArray", "(", "$", "pk", ",", "$", "depth", ")", ";", "return", "(", "!", "is_array", "(", "$", "wrappers", ")", "||", "empty", "(", "$", "wrappers", ")", ")", "?", "null", ":", "$", "wrappers", "[", "0", "]", ";", "}" ]
Fetches a branch of a tree, returning the starting node of the branch. All children and descendants are pre-populated. @param mixed $pk the primary key used to locate the node to traverse the tree from @param int $depth the depth to retrieve or null for unlimited @return NodeWrapper $branch
[ "Fetches", "a", "branch", "of", "a", "tree", "returning", "the", "starting", "node", "of", "the", "branch", ".", "All", "children", "and", "descendants", "are", "pre", "-", "populated", "." ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L147-L152
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.fetchBranchAsArray
public function fetchBranchAsArray($pk, $depth=null) { $config = $this->getConfiguration(); $lftField = $config->getLeftFieldName(); $rgtField = $config->getRightFieldName(); $rootField = $config->getRootFieldName(); $hasManyRoots = $config->hasManyRoots(); if($depth === 0) { return array(); } $node = $this->getEntityManager()->find($this->getConfiguration()->getClassname(), $pk); if(!$node) { return array(); } $qb = $config->getBaseQueryBuilder(); $alias = $config->getQueryBuilderAlias(); $qb->andWhere("$alias.$lftField >= :lowerbound") ->setParameter('lowerbound', $node->getLeftValue()) ->andWhere("$alias.$rgtField <= :upperbound") ->setParameter('upperbound', $node->getRightValue()) ->orderBy("$alias.$lftField", "ASC"); // TODO: Add support for depth via a cross join if($hasManyRoots) { $qb->andWhere("$alias.$rootField = :rootid") ->setParameter('rootid', $node->getRootValue()); } $q = $qb->getQuery(); if ($this->config->isQueryHintSet()){ $q = $this->addHintToQuery($q); } $nodes = $q->execute(); // @codeCoverageIgnoreStart if(empty($nodes)) { return null; } // @codeCoverageIgnoreEnd // TODO: Filter depth using a cross join instead of this if($depth !== null) { $nodes = $this->filterNodeDepth($nodes, $depth); } $wrappers = array(); foreach($nodes as $node) { $wrappers[] = $this->wrapNode($node); } $this->buildTree($wrappers); return $wrappers; }
php
public function fetchBranchAsArray($pk, $depth=null) { $config = $this->getConfiguration(); $lftField = $config->getLeftFieldName(); $rgtField = $config->getRightFieldName(); $rootField = $config->getRootFieldName(); $hasManyRoots = $config->hasManyRoots(); if($depth === 0) { return array(); } $node = $this->getEntityManager()->find($this->getConfiguration()->getClassname(), $pk); if(!$node) { return array(); } $qb = $config->getBaseQueryBuilder(); $alias = $config->getQueryBuilderAlias(); $qb->andWhere("$alias.$lftField >= :lowerbound") ->setParameter('lowerbound', $node->getLeftValue()) ->andWhere("$alias.$rgtField <= :upperbound") ->setParameter('upperbound', $node->getRightValue()) ->orderBy("$alias.$lftField", "ASC"); // TODO: Add support for depth via a cross join if($hasManyRoots) { $qb->andWhere("$alias.$rootField = :rootid") ->setParameter('rootid', $node->getRootValue()); } $q = $qb->getQuery(); if ($this->config->isQueryHintSet()){ $q = $this->addHintToQuery($q); } $nodes = $q->execute(); // @codeCoverageIgnoreStart if(empty($nodes)) { return null; } // @codeCoverageIgnoreEnd // TODO: Filter depth using a cross join instead of this if($depth !== null) { $nodes = $this->filterNodeDepth($nodes, $depth); } $wrappers = array(); foreach($nodes as $node) { $wrappers[] = $this->wrapNode($node); } $this->buildTree($wrappers); return $wrappers; }
[ "public", "function", "fetchBranchAsArray", "(", "$", "pk", ",", "$", "depth", "=", "null", ")", "{", "$", "config", "=", "$", "this", "->", "getConfiguration", "(", ")", ";", "$", "lftField", "=", "$", "config", "->", "getLeftFieldName", "(", ")", ";", "$", "rgtField", "=", "$", "config", "->", "getRightFieldName", "(", ")", ";", "$", "rootField", "=", "$", "config", "->", "getRootFieldName", "(", ")", ";", "$", "hasManyRoots", "=", "$", "config", "->", "hasManyRoots", "(", ")", ";", "if", "(", "$", "depth", "===", "0", ")", "{", "return", "array", "(", ")", ";", "}", "$", "node", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "find", "(", "$", "this", "->", "getConfiguration", "(", ")", "->", "getClassname", "(", ")", ",", "$", "pk", ")", ";", "if", "(", "!", "$", "node", ")", "{", "return", "array", "(", ")", ";", "}", "$", "qb", "=", "$", "config", "->", "getBaseQueryBuilder", "(", ")", ";", "$", "alias", "=", "$", "config", "->", "getQueryBuilderAlias", "(", ")", ";", "$", "qb", "->", "andWhere", "(", "\"$alias.$lftField >= :lowerbound\"", ")", "->", "setParameter", "(", "'lowerbound'", ",", "$", "node", "->", "getLeftValue", "(", ")", ")", "->", "andWhere", "(", "\"$alias.$rgtField <= :upperbound\"", ")", "->", "setParameter", "(", "'upperbound'", ",", "$", "node", "->", "getRightValue", "(", ")", ")", "->", "orderBy", "(", "\"$alias.$lftField\"", ",", "\"ASC\"", ")", ";", "// TODO: Add support for depth via a cross join", "if", "(", "$", "hasManyRoots", ")", "{", "$", "qb", "->", "andWhere", "(", "\"$alias.$rootField = :rootid\"", ")", "->", "setParameter", "(", "'rootid'", ",", "$", "node", "->", "getRootValue", "(", ")", ")", ";", "}", "$", "q", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "if", "(", "$", "this", "->", "config", "->", "isQueryHintSet", "(", ")", ")", "{", "$", "q", "=", "$", "this", "->", "addHintToQuery", "(", "$", "q", ")", ";", "}", "$", "nodes", "=", "$", "q", "->", "execute", "(", ")", ";", "// @codeCoverageIgnoreStart", "if", "(", "empty", "(", "$", "nodes", ")", ")", "{", "return", "null", ";", "}", "// @codeCoverageIgnoreEnd", "// TODO: Filter depth using a cross join instead of this", "if", "(", "$", "depth", "!==", "null", ")", "{", "$", "nodes", "=", "$", "this", "->", "filterNodeDepth", "(", "$", "nodes", ",", "$", "depth", ")", ";", "}", "$", "wrappers", "=", "array", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "wrappers", "[", "]", "=", "$", "this", "->", "wrapNode", "(", "$", "node", ")", ";", "}", "$", "this", "->", "buildTree", "(", "$", "wrappers", ")", ";", "return", "$", "wrappers", ";", "}" ]
Fetches a branch of a tree, returning a flat array of node wrappers with parent, children, ancestors and descendants pre-populated. @param mixed $pk the primary key used to locate the node to traverse the tree from @param int $depth the depth to retrieve or null for unlimited @return array
[ "Fetches", "a", "branch", "of", "a", "tree", "returning", "a", "flat", "array", "of", "node", "wrappers", "with", "parent", "children", "ancestors", "and", "descendants", "pre", "-", "populated", "." ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L165-L230
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.createRoot
public function createRoot(Node $node) { if($node instanceof NodeWrapper) { throw new \InvalidArgumentException('Can\'t create a root node from a NodeWrapper node'); } $node->setLeftValue(1); $node->setRightValue(2); if($this->getConfiguration()->hasManyRoots()) { $rootValue = $node->getId(); if($rootValue === null) { // Set a temporary value in case wrapped node requires root value to be set $node->setRootValue(0); $this->getEntityManager()->persist($node); $this->getEntityManager()->flush(); $rootValue = $node->getId(); } if($rootValue === null) { // @codeCoverageIgnoreStart throw new \RuntimeException('Node must have an identifier available via getId()'); // @codeCoverageIgnoreEnd } $node->setRootValue($rootValue); } $this->getEntityManager()->persist($node); $this->getEntityManager()->flush(); return $this->wrapNode($node); }
php
public function createRoot(Node $node) { if($node instanceof NodeWrapper) { throw new \InvalidArgumentException('Can\'t create a root node from a NodeWrapper node'); } $node->setLeftValue(1); $node->setRightValue(2); if($this->getConfiguration()->hasManyRoots()) { $rootValue = $node->getId(); if($rootValue === null) { // Set a temporary value in case wrapped node requires root value to be set $node->setRootValue(0); $this->getEntityManager()->persist($node); $this->getEntityManager()->flush(); $rootValue = $node->getId(); } if($rootValue === null) { // @codeCoverageIgnoreStart throw new \RuntimeException('Node must have an identifier available via getId()'); // @codeCoverageIgnoreEnd } $node->setRootValue($rootValue); } $this->getEntityManager()->persist($node); $this->getEntityManager()->flush(); return $this->wrapNode($node); }
[ "public", "function", "createRoot", "(", "Node", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "NodeWrapper", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Can\\'t create a root node from a NodeWrapper node'", ")", ";", "}", "$", "node", "->", "setLeftValue", "(", "1", ")", ";", "$", "node", "->", "setRightValue", "(", "2", ")", ";", "if", "(", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasManyRoots", "(", ")", ")", "{", "$", "rootValue", "=", "$", "node", "->", "getId", "(", ")", ";", "if", "(", "$", "rootValue", "===", "null", ")", "{", "// Set a temporary value in case wrapped node requires root value to be set", "$", "node", "->", "setRootValue", "(", "0", ")", ";", "$", "this", "->", "getEntityManager", "(", ")", "->", "persist", "(", "$", "node", ")", ";", "$", "this", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "$", "rootValue", "=", "$", "node", "->", "getId", "(", ")", ";", "}", "if", "(", "$", "rootValue", "===", "null", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "RuntimeException", "(", "'Node must have an identifier available via getId()'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "$", "node", "->", "setRootValue", "(", "$", "rootValue", ")", ";", "}", "$", "this", "->", "getEntityManager", "(", ")", "->", "persist", "(", "$", "node", ")", ";", "$", "this", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "wrapNode", "(", "$", "node", ")", ";", "}" ]
Creates a new root node @param Node @return NodeWrapper
[ "Creates", "a", "new", "root", "node" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L240-L277
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.wrapNode
public function wrapNode(Node $node) { if($node instanceof NodeWrapper) { throw new \InvalidArgumentException('Can\'t wrap a NodeWrapper node'); } $oid = spl_object_hash($node); if(!isset($this->wrappers[$oid]) || $this->wrappers[$oid]->getNode() !== $node) { $this->wrappers[$oid] = new NodeWrapper($node, $this); } return $this->wrappers[$oid]; }
php
public function wrapNode(Node $node) { if($node instanceof NodeWrapper) { throw new \InvalidArgumentException('Can\'t wrap a NodeWrapper node'); } $oid = spl_object_hash($node); if(!isset($this->wrappers[$oid]) || $this->wrappers[$oid]->getNode() !== $node) { $this->wrappers[$oid] = new NodeWrapper($node, $this); } return $this->wrappers[$oid]; }
[ "public", "function", "wrapNode", "(", "Node", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "NodeWrapper", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Can\\'t wrap a NodeWrapper node'", ")", ";", "}", "$", "oid", "=", "spl_object_hash", "(", "$", "node", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "wrappers", "[", "$", "oid", "]", ")", "||", "$", "this", "->", "wrappers", "[", "$", "oid", "]", "->", "getNode", "(", ")", "!==", "$", "node", ")", "{", "$", "this", "->", "wrappers", "[", "$", "oid", "]", "=", "new", "NodeWrapper", "(", "$", "node", ",", "$", "this", ")", ";", "}", "return", "$", "this", "->", "wrappers", "[", "$", "oid", "]", ";", "}" ]
wraps the node using the NodeWrapper class @param Node $node @return NodeWrapper
[ "wraps", "the", "node", "using", "the", "NodeWrapper", "class" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L287-L301
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.updateLeftValues
public function updateLeftValues($first, $last, $delta, $rootVal=null) { $hasManyRoots = $this->getConfiguration()->hasManyRoots(); foreach($this->wrappers as $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $rootVal)) { if($wrapper->getLeftValue() >= $first && ($last === 0 || $wrapper->getLeftValue() <= $last)) { $wrapper->setLeftValue($wrapper->getLeftValue() + $delta); $wrapper->invalidate(); } } } }
php
public function updateLeftValues($first, $last, $delta, $rootVal=null) { $hasManyRoots = $this->getConfiguration()->hasManyRoots(); foreach($this->wrappers as $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $rootVal)) { if($wrapper->getLeftValue() >= $first && ($last === 0 || $wrapper->getLeftValue() <= $last)) { $wrapper->setLeftValue($wrapper->getLeftValue() + $delta); $wrapper->invalidate(); } } } }
[ "public", "function", "updateLeftValues", "(", "$", "first", ",", "$", "last", ",", "$", "delta", ",", "$", "rootVal", "=", "null", ")", "{", "$", "hasManyRoots", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasManyRoots", "(", ")", ";", "foreach", "(", "$", "this", "->", "wrappers", "as", "$", "wrapper", ")", "{", "if", "(", "!", "$", "hasManyRoots", "||", "(", "$", "wrapper", "->", "getRootValue", "(", ")", "==", "$", "rootVal", ")", ")", "{", "if", "(", "$", "wrapper", "->", "getLeftValue", "(", ")", ">=", "$", "first", "&&", "(", "$", "last", "===", "0", "||", "$", "wrapper", "->", "getLeftValue", "(", ")", "<=", "$", "last", ")", ")", "{", "$", "wrapper", "->", "setLeftValue", "(", "$", "wrapper", "->", "getLeftValue", "(", ")", "+", "$", "delta", ")", ";", "$", "wrapper", "->", "invalidate", "(", ")", ";", "}", "}", "}", "}" ]
Internal Updates the left values of managed nodes @param int $first first left value to shift @param int $last last left value to shift, or 0 @param int $delta offset to shift by @param mixed $rootVal the root value of entities to act upon
[ "Internal", "Updates", "the", "left", "values", "of", "managed", "nodes" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L352-L367
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.updateRightValues
public function updateRightValues($first, $last, $delta, $rootVal=null) { $hasManyRoots = $this->getConfiguration()->hasManyRoots(); foreach($this->wrappers as $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $rootVal)) { if($wrapper->getRightValue() >= $first && ($last === 0 || $wrapper->getRightValue() <= $last)) { $wrapper->setRightValue($wrapper->getRightValue() + $delta); $wrapper->invalidate(); } } } }
php
public function updateRightValues($first, $last, $delta, $rootVal=null) { $hasManyRoots = $this->getConfiguration()->hasManyRoots(); foreach($this->wrappers as $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $rootVal)) { if($wrapper->getRightValue() >= $first && ($last === 0 || $wrapper->getRightValue() <= $last)) { $wrapper->setRightValue($wrapper->getRightValue() + $delta); $wrapper->invalidate(); } } } }
[ "public", "function", "updateRightValues", "(", "$", "first", ",", "$", "last", ",", "$", "delta", ",", "$", "rootVal", "=", "null", ")", "{", "$", "hasManyRoots", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasManyRoots", "(", ")", ";", "foreach", "(", "$", "this", "->", "wrappers", "as", "$", "wrapper", ")", "{", "if", "(", "!", "$", "hasManyRoots", "||", "(", "$", "wrapper", "->", "getRootValue", "(", ")", "==", "$", "rootVal", ")", ")", "{", "if", "(", "$", "wrapper", "->", "getRightValue", "(", ")", ">=", "$", "first", "&&", "(", "$", "last", "===", "0", "||", "$", "wrapper", "->", "getRightValue", "(", ")", "<=", "$", "last", ")", ")", "{", "$", "wrapper", "->", "setRightValue", "(", "$", "wrapper", "->", "getRightValue", "(", ")", "+", "$", "delta", ")", ";", "$", "wrapper", "->", "invalidate", "(", ")", ";", "}", "}", "}", "}" ]
Internal Updates the right values of managed nodes @param int $first first right value to shift @param int $last last right value to shift, or 0 @param int $delta offset to shift by @param mixed $rootVal the root value of entities to act upon
[ "Internal", "Updates", "the", "right", "values", "of", "managed", "nodes" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L380-L395
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.updateValues
public function updateValues($first, $last, $delta, $oldRoot=null, $newRoot=null) { if(!$this->wrappers) { return; } $hasManyRoots = $this->getConfiguration()->hasManyRoots(); foreach($this->wrappers as $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $oldRoot)) { if($wrapper->getLeftValue() >= $first && ($last === 0 || $wrapper->getRightValue() <= $last)) { if($delta !== 0) { $wrapper->setLeftValue($wrapper->getLeftValue() + $delta); $wrapper->setRightValue($wrapper->getRightValue() + $delta); } if($hasManyRoots && $newRoot !== null) { $wrapper->setRootValue($newRoot); } } } } }
php
public function updateValues($first, $last, $delta, $oldRoot=null, $newRoot=null) { if(!$this->wrappers) { return; } $hasManyRoots = $this->getConfiguration()->hasManyRoots(); foreach($this->wrappers as $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $oldRoot)) { if($wrapper->getLeftValue() >= $first && ($last === 0 || $wrapper->getRightValue() <= $last)) { if($delta !== 0) { $wrapper->setLeftValue($wrapper->getLeftValue() + $delta); $wrapper->setRightValue($wrapper->getRightValue() + $delta); } if($hasManyRoots && $newRoot !== null) { $wrapper->setRootValue($newRoot); } } } } }
[ "public", "function", "updateValues", "(", "$", "first", ",", "$", "last", ",", "$", "delta", ",", "$", "oldRoot", "=", "null", ",", "$", "newRoot", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "wrappers", ")", "{", "return", ";", "}", "$", "hasManyRoots", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasManyRoots", "(", ")", ";", "foreach", "(", "$", "this", "->", "wrappers", "as", "$", "wrapper", ")", "{", "if", "(", "!", "$", "hasManyRoots", "||", "(", "$", "wrapper", "->", "getRootValue", "(", ")", "==", "$", "oldRoot", ")", ")", "{", "if", "(", "$", "wrapper", "->", "getLeftValue", "(", ")", ">=", "$", "first", "&&", "(", "$", "last", "===", "0", "||", "$", "wrapper", "->", "getRightValue", "(", ")", "<=", "$", "last", ")", ")", "{", "if", "(", "$", "delta", "!==", "0", ")", "{", "$", "wrapper", "->", "setLeftValue", "(", "$", "wrapper", "->", "getLeftValue", "(", ")", "+", "$", "delta", ")", ";", "$", "wrapper", "->", "setRightValue", "(", "$", "wrapper", "->", "getRightValue", "(", ")", "+", "$", "delta", ")", ";", "}", "if", "(", "$", "hasManyRoots", "&&", "$", "newRoot", "!==", "null", ")", "{", "$", "wrapper", "->", "setRootValue", "(", "$", "newRoot", ")", ";", "}", "}", "}", "}", "}" ]
Internal Updates the left, right and root values of managed nodes @param int $first lowerbound (lft/rgt) of nodes to update @param int $last upperbound (lft/rgt) of nodes to update, or 0 @param int $delta delta to add to lft/rgt values (can be negative) @param mixed $oldRoot the old root value of entities to act upon @param mixed $newRoot the new root value to set (or null to not change root)
[ "Internal", "Updates", "the", "left", "right", "and", "root", "values", "of", "managed", "nodes" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L408-L435
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.removeNodes
public function removeNodes($left, $right, $root=null) { $hasManyRoots = $this->getConfiguration()->hasManyRoots(); $removed = array(); foreach($this->wrappers as $oid => $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $root)) { if($wrapper->getLeftValue() >= $left && $wrapper->getRightValue() <= $right) { $removed[$oid] = $wrapper; } } } foreach($removed as $key => $wrapper) { unset($this->wrappers[$key]); $wrapper->setLeftValue(0); $wrapper->setRightValue(0); if($hasManyRoots) { $wrapper->setRootValue(0); } $this->getEntityManager()->detach($wrapper->getNode()); } }
php
public function removeNodes($left, $right, $root=null) { $hasManyRoots = $this->getConfiguration()->hasManyRoots(); $removed = array(); foreach($this->wrappers as $oid => $wrapper) { if(!$hasManyRoots || ($wrapper->getRootValue() == $root)) { if($wrapper->getLeftValue() >= $left && $wrapper->getRightValue() <= $right) { $removed[$oid] = $wrapper; } } } foreach($removed as $key => $wrapper) { unset($this->wrappers[$key]); $wrapper->setLeftValue(0); $wrapper->setRightValue(0); if($hasManyRoots) { $wrapper->setRootValue(0); } $this->getEntityManager()->detach($wrapper->getNode()); } }
[ "public", "function", "removeNodes", "(", "$", "left", ",", "$", "right", ",", "$", "root", "=", "null", ")", "{", "$", "hasManyRoots", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasManyRoots", "(", ")", ";", "$", "removed", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "wrappers", "as", "$", "oid", "=>", "$", "wrapper", ")", "{", "if", "(", "!", "$", "hasManyRoots", "||", "(", "$", "wrapper", "->", "getRootValue", "(", ")", "==", "$", "root", ")", ")", "{", "if", "(", "$", "wrapper", "->", "getLeftValue", "(", ")", ">=", "$", "left", "&&", "$", "wrapper", "->", "getRightValue", "(", ")", "<=", "$", "right", ")", "{", "$", "removed", "[", "$", "oid", "]", "=", "$", "wrapper", ";", "}", "}", "}", "foreach", "(", "$", "removed", "as", "$", "key", "=>", "$", "wrapper", ")", "{", "unset", "(", "$", "this", "->", "wrappers", "[", "$", "key", "]", ")", ";", "$", "wrapper", "->", "setLeftValue", "(", "0", ")", ";", "$", "wrapper", "->", "setRightValue", "(", "0", ")", ";", "if", "(", "$", "hasManyRoots", ")", "{", "$", "wrapper", "->", "setRootValue", "(", "0", ")", ";", "}", "$", "this", "->", "getEntityManager", "(", ")", "->", "detach", "(", "$", "wrapper", "->", "getNode", "(", ")", ")", ";", "}", "}" ]
Internal Removes managed nodes @param int $left @param int $right @param mixed $root
[ "Internal", "Removes", "managed", "nodes" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L446-L473
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.filterNodeDepth
public function filterNodeDepth($nodes, $depth) { if(empty($nodes) || $depth === 0) { return array(); } $newNodes = array(); $stack = array(); $level = 0; foreach($nodes as $node) { $parent = end($stack); while($parent && $node->getLeftValue() > $parent->getRightValue()) { array_pop($stack); $parent = end($stack); $level--; } if($level < $depth) { $newNodes[] = $node; } if(($node->getRightValue() - $node->getLeftValue()) > 1) { array_push($stack, $node); $level++; } } return $newNodes; }
php
public function filterNodeDepth($nodes, $depth) { if(empty($nodes) || $depth === 0) { return array(); } $newNodes = array(); $stack = array(); $level = 0; foreach($nodes as $node) { $parent = end($stack); while($parent && $node->getLeftValue() > $parent->getRightValue()) { array_pop($stack); $parent = end($stack); $level--; } if($level < $depth) { $newNodes[] = $node; } if(($node->getRightValue() - $node->getLeftValue()) > 1) { array_push($stack, $node); $level++; } } return $newNodes; }
[ "public", "function", "filterNodeDepth", "(", "$", "nodes", ",", "$", "depth", ")", "{", "if", "(", "empty", "(", "$", "nodes", ")", "||", "$", "depth", "===", "0", ")", "{", "return", "array", "(", ")", ";", "}", "$", "newNodes", "=", "array", "(", ")", ";", "$", "stack", "=", "array", "(", ")", ";", "$", "level", "=", "0", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "parent", "=", "end", "(", "$", "stack", ")", ";", "while", "(", "$", "parent", "&&", "$", "node", "->", "getLeftValue", "(", ")", ">", "$", "parent", "->", "getRightValue", "(", ")", ")", "{", "array_pop", "(", "$", "stack", ")", ";", "$", "parent", "=", "end", "(", "$", "stack", ")", ";", "$", "level", "--", ";", "}", "if", "(", "$", "level", "<", "$", "depth", ")", "{", "$", "newNodes", "[", "]", "=", "$", "node", ";", "}", "if", "(", "(", "$", "node", "->", "getRightValue", "(", ")", "-", "$", "node", "->", "getLeftValue", "(", ")", ")", ">", "1", ")", "{", "array_push", "(", "$", "stack", ",", "$", "node", ")", ";", "$", "level", "++", ";", "}", "}", "return", "$", "newNodes", ";", "}" ]
Internal Filters an array of nodes by depth @param array array of Node instances @param int $depth the depth to filter to @return array array of Node instances
[ "Internal", "Filters", "an", "array", "of", "nodes", "by", "depth" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L485-L519
train
devlabmtl/haven-core
Lib/NestedSet/Manager.php
Manager.addHintToQuery
public function addHintToQuery(\Doctrine\ORM\Query $query) { return $query->setHint($this->getConfiguration()->GetQueryHintName(), $this->getConfiguration()->GetQueryHintValue()); }
php
public function addHintToQuery(\Doctrine\ORM\Query $query) { return $query->setHint($this->getConfiguration()->GetQueryHintName(), $this->getConfiguration()->GetQueryHintValue()); }
[ "public", "function", "addHintToQuery", "(", "\\", "Doctrine", "\\", "ORM", "\\", "Query", "$", "query", ")", "{", "return", "$", "query", "->", "setHint", "(", "$", "this", "->", "getConfiguration", "(", ")", "->", "GetQueryHintName", "(", ")", ",", "$", "this", "->", "getConfiguration", "(", ")", "->", "GetQueryHintValue", "(", ")", ")", ";", "}" ]
Adds a Query hint to a Query Object @param \Doctrine\ORM\Query $query @return \Doctrine\ORM\Query
[ "Adds", "a", "Query", "hint", "to", "a", "Query", "Object" ]
f13410f996fd4002efafe482b927adadb211dec8
https://github.com/devlabmtl/haven-core/blob/f13410f996fd4002efafe482b927adadb211dec8/Lib/NestedSet/Manager.php#L604-L607
train
GetOlympus/olympus-map-field
src/Map/Map.php
Map.getMapsOptions
protected function getMapsOptions() { return [ 'dragndrop' => Translate::t('map.options.dragndrop', [], 'mapfield'), 'streetview' => Translate::t('map.options.streetview', [], 'mapfield'), 'zoomcontrol' => Translate::t('map.options.zoomcontrol', [], 'mapfield'), 'mapcontrol' => Translate::t('map.options.mapcontrol', [], 'mapfield'), 'scalecontrol' => Translate::t('map.options.scalecontrol', [], 'mapfield'), 'pancontrol' => Translate::t('map.options.pancontrol', [], 'mapfield'), 'rotatecontrol' => Translate::t('map.options.rotatecontrol', [], 'mapfield'), 'rotatecontroloptions' => Translate::t('map.options.rotatecontroloptions', [], 'mapfield'), 'scrollwheel' => Translate::t('map.options.scrollwheel', [], 'mapfield'), 'overviewmapcontrol' => Translate::t('map.options.overviewmapcontrol', [], 'mapfield'), 'overviewmapcontroloptions' => Translate::t('map.options.overviewmapcontroloptions', [], 'mapfield'), ]; }
php
protected function getMapsOptions() { return [ 'dragndrop' => Translate::t('map.options.dragndrop', [], 'mapfield'), 'streetview' => Translate::t('map.options.streetview', [], 'mapfield'), 'zoomcontrol' => Translate::t('map.options.zoomcontrol', [], 'mapfield'), 'mapcontrol' => Translate::t('map.options.mapcontrol', [], 'mapfield'), 'scalecontrol' => Translate::t('map.options.scalecontrol', [], 'mapfield'), 'pancontrol' => Translate::t('map.options.pancontrol', [], 'mapfield'), 'rotatecontrol' => Translate::t('map.options.rotatecontrol', [], 'mapfield'), 'rotatecontroloptions' => Translate::t('map.options.rotatecontroloptions', [], 'mapfield'), 'scrollwheel' => Translate::t('map.options.scrollwheel', [], 'mapfield'), 'overviewmapcontrol' => Translate::t('map.options.overviewmapcontrol', [], 'mapfield'), 'overviewmapcontroloptions' => Translate::t('map.options.overviewmapcontroloptions', [], 'mapfield'), ]; }
[ "protected", "function", "getMapsOptions", "(", ")", "{", "return", "[", "'dragndrop'", "=>", "Translate", "::", "t", "(", "'map.options.dragndrop'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'streetview'", "=>", "Translate", "::", "t", "(", "'map.options.streetview'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'zoomcontrol'", "=>", "Translate", "::", "t", "(", "'map.options.zoomcontrol'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'mapcontrol'", "=>", "Translate", "::", "t", "(", "'map.options.mapcontrol'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'scalecontrol'", "=>", "Translate", "::", "t", "(", "'map.options.scalecontrol'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'pancontrol'", "=>", "Translate", "::", "t", "(", "'map.options.pancontrol'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'rotatecontrol'", "=>", "Translate", "::", "t", "(", "'map.options.rotatecontrol'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'rotatecontroloptions'", "=>", "Translate", "::", "t", "(", "'map.options.rotatecontroloptions'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'scrollwheel'", "=>", "Translate", "::", "t", "(", "'map.options.scrollwheel'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'overviewmapcontrol'", "=>", "Translate", "::", "t", "(", "'map.options.overviewmapcontrol'", ",", "[", "]", ",", "'mapfield'", ")", ",", "'overviewmapcontroloptions'", "=>", "Translate", "::", "t", "(", "'map.options.overviewmapcontroloptions'", ",", "[", "]", ",", "'mapfield'", ")", ",", "]", ";", "}" ]
Return all available maps options. @return array $options
[ "Return", "all", "available", "maps", "options", "." ]
8b8d860d3916a9bf033aa11811ee96417704a446
https://github.com/GetOlympus/olympus-map-field/blob/8b8d860d3916a9bf033aa11811ee96417704a446/src/Map/Map.php#L137-L155
train
PenoaksDev/Milky-Framework
src/Milky/Annotations/CachedReader.php
CachedReader.saveToCache
private function saveToCache( $rawCacheKey, $value ) { $cacheKey = $rawCacheKey . self::$CACHE_SALT; $this->cache->save( $cacheKey, $value ); if ( $this->debug ) $this->cache->save( '[C]' . $cacheKey, time() ); }
php
private function saveToCache( $rawCacheKey, $value ) { $cacheKey = $rawCacheKey . self::$CACHE_SALT; $this->cache->save( $cacheKey, $value ); if ( $this->debug ) $this->cache->save( '[C]' . $cacheKey, time() ); }
[ "private", "function", "saveToCache", "(", "$", "rawCacheKey", ",", "$", "value", ")", "{", "$", "cacheKey", "=", "$", "rawCacheKey", ".", "self", "::", "$", "CACHE_SALT", ";", "$", "this", "->", "cache", "->", "save", "(", "$", "cacheKey", ",", "$", "value", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "$", "this", "->", "cache", "->", "save", "(", "'[C]'", ".", "$", "cacheKey", ",", "time", "(", ")", ")", ";", "}" ]
Saves a value to the cache. @param string $rawCacheKey The cache key. @param mixed $value The value. @return void
[ "Saves", "a", "value", "to", "the", "cache", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Annotations/CachedReader.php#L181-L187
train
PenoaksDev/Milky-Framework
src/Milky/Annotations/CachedReader.php
CachedReader.isCacheFresh
private function isCacheFresh( $cacheKey, \ReflectionClass $class ) { if ( false === $filename = $class->getFileName() ) return true; return $this->cache->fetch( '[C]' . $cacheKey ) >= filemtime( $filename ); }
php
private function isCacheFresh( $cacheKey, \ReflectionClass $class ) { if ( false === $filename = $class->getFileName() ) return true; return $this->cache->fetch( '[C]' . $cacheKey ) >= filemtime( $filename ); }
[ "private", "function", "isCacheFresh", "(", "$", "cacheKey", ",", "\\", "ReflectionClass", "$", "class", ")", "{", "if", "(", "false", "===", "$", "filename", "=", "$", "class", "->", "getFileName", "(", ")", ")", "return", "true", ";", "return", "$", "this", "->", "cache", "->", "fetch", "(", "'[C]'", ".", "$", "cacheKey", ")", ">=", "filemtime", "(", "$", "filename", ")", ";", "}" ]
Checks if the cache is fresh. @param string $cacheKey @param \ReflectionClass $class @return boolean
[ "Checks", "if", "the", "cache", "is", "fresh", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Annotations/CachedReader.php#L197-L203
train
koolkode/config
src/ConfigurationLoader.php
ConfigurationLoader.findLoader
public function findLoader(\SplFileInfo $source) { foreach($this->loaders as $loader) { if($loader->isSupported($source)) { return $loader; } } throw new \OutOfBoundsException(sprintf('No configuration loader found for "%s"', $source->getPathname())); }
php
public function findLoader(\SplFileInfo $source) { foreach($this->loaders as $loader) { if($loader->isSupported($source)) { return $loader; } } throw new \OutOfBoundsException(sprintf('No configuration loader found for "%s"', $source->getPathname())); }
[ "public", "function", "findLoader", "(", "\\", "SplFileInfo", "$", "source", ")", "{", "foreach", "(", "$", "this", "->", "loaders", "as", "$", "loader", ")", "{", "if", "(", "$", "loader", "->", "isSupported", "(", "$", "source", ")", ")", "{", "return", "$", "loader", ";", "}", "}", "throw", "new", "\\", "OutOfBoundsException", "(", "sprintf", "(", "'No configuration loader found for \"%s\"'", ",", "$", "source", "->", "getPathname", "(", ")", ")", ")", ";", "}" ]
Picks a config loader for the given file and returns it. @param \SplFileInfo $source @return ConfigurationLoaderInterface @throws \OutOfBoundsException When no loader is able to load the given file.
[ "Picks", "a", "config", "loader", "for", "the", "given", "file", "and", "returns", "it", "." ]
ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6
https://github.com/koolkode/config/blob/ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6/src/ConfigurationLoader.php#L52-L63
train
bkstg/schedule-bundle
Validator/Constraints/UniqueCollectionPropertyValidator.php
UniqueCollectionPropertyValidator.validate
public function validate($value, Constraint $constraint): void { // Build a list of values. $item_values = []; foreach ($value as $item) { $item_value = $this->property_accessor->getValue($item, $constraint->property); // If any value is repeated build a violation. if (isset($item_values[$item_value])) { $this->context->buildViolation($constraint->message) ->setParameter('{{ string }}', $constraint->property) ->addViolation(); } $item_values[$item_value] = true; } }
php
public function validate($value, Constraint $constraint): void { // Build a list of values. $item_values = []; foreach ($value as $item) { $item_value = $this->property_accessor->getValue($item, $constraint->property); // If any value is repeated build a violation. if (isset($item_values[$item_value])) { $this->context->buildViolation($constraint->message) ->setParameter('{{ string }}', $constraint->property) ->addViolation(); } $item_values[$item_value] = true; } }
[ "public", "function", "validate", "(", "$", "value", ",", "Constraint", "$", "constraint", ")", ":", "void", "{", "// Build a list of values.", "$", "item_values", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "item", ")", "{", "$", "item_value", "=", "$", "this", "->", "property_accessor", "->", "getValue", "(", "$", "item", ",", "$", "constraint", "->", "property", ")", ";", "// If any value is repeated build a violation.", "if", "(", "isset", "(", "$", "item_values", "[", "$", "item_value", "]", ")", ")", "{", "$", "this", "->", "context", "->", "buildViolation", "(", "$", "constraint", "->", "message", ")", "->", "setParameter", "(", "'{{ string }}'", ",", "$", "constraint", "->", "property", ")", "->", "addViolation", "(", ")", ";", "}", "$", "item_values", "[", "$", "item_value", "]", "=", "true", ";", "}", "}" ]
Validate a constraint. @param mixed $value The value being passed in. @param Constraint $constraint The constraint to be checked. @return void
[ "Validate", "a", "constraint", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Validator/Constraints/UniqueCollectionPropertyValidator.php#L40-L55
train
theopera/framework
src/Component/Http/Request.php
Request.getPathInfo
public function getPathInfo() { if ($this->pathInfo === null) { $end = strpos($this->uri, '?'); if ($end === false) { $this->pathInfo = $this->uri; }else{ $this->pathInfo = substr($this->uri, 0, $end); } if (empty($this->pathInfo)) { $this->pathInfo = '/'; } } return $this->pathInfo; }
php
public function getPathInfo() { if ($this->pathInfo === null) { $end = strpos($this->uri, '?'); if ($end === false) { $this->pathInfo = $this->uri; }else{ $this->pathInfo = substr($this->uri, 0, $end); } if (empty($this->pathInfo)) { $this->pathInfo = '/'; } } return $this->pathInfo; }
[ "public", "function", "getPathInfo", "(", ")", "{", "if", "(", "$", "this", "->", "pathInfo", "===", "null", ")", "{", "$", "end", "=", "strpos", "(", "$", "this", "->", "uri", ",", "'?'", ")", ";", "if", "(", "$", "end", "===", "false", ")", "{", "$", "this", "->", "pathInfo", "=", "$", "this", "->", "uri", ";", "}", "else", "{", "$", "this", "->", "pathInfo", "=", "substr", "(", "$", "this", "->", "uri", ",", "0", ",", "$", "end", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "pathInfo", ")", ")", "{", "$", "this", "->", "pathInfo", "=", "'/'", ";", "}", "}", "return", "$", "this", "->", "pathInfo", ";", "}" ]
Get the path info which is the uri without the query parameters @return string
[ "Get", "the", "path", "info", "which", "is", "the", "uri", "without", "the", "query", "parameters" ]
fa6165d3891a310faa580c81dee49a63c150c711
https://github.com/theopera/framework/blob/fa6165d3891a310faa580c81dee49a63c150c711/src/Component/Http/Request.php#L226-L243
train
fridge-project/dbal
src/Fridge/DBAL/Driver/Connection/MysqliConnection.php
MysqliConnection.getMaxAllowedPacket
public function getMaxAllowedPacket() { if ($this->maxAllowedPacket === null) { $statement = $this->prepare('SELECT @@global.max_allowed_packet'); $statement->execute(); $this->maxAllowedPacket = (int) $statement->fetchColumn(); } return $this->maxAllowedPacket; }
php
public function getMaxAllowedPacket() { if ($this->maxAllowedPacket === null) { $statement = $this->prepare('SELECT @@global.max_allowed_packet'); $statement->execute(); $this->maxAllowedPacket = (int) $statement->fetchColumn(); } return $this->maxAllowedPacket; }
[ "public", "function", "getMaxAllowedPacket", "(", ")", "{", "if", "(", "$", "this", "->", "maxAllowedPacket", "===", "null", ")", "{", "$", "statement", "=", "$", "this", "->", "prepare", "(", "'SELECT @@global.max_allowed_packet'", ")", ";", "$", "statement", "->", "execute", "(", ")", ";", "$", "this", "->", "maxAllowedPacket", "=", "(", "int", ")", "$", "statement", "->", "fetchColumn", "(", ")", ";", "}", "return", "$", "this", "->", "maxAllowedPacket", ";", "}" ]
Gets the MySQL max allowed packet constant. @link http://dev.mysql.com/doc/refman/5.0/en/program-variables.html @return integer The max allowed packet.
[ "Gets", "the", "MySQL", "max", "allowed", "packet", "constant", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Driver/Connection/MysqliConnection.php#L188-L198
train
agentmedia/phine-core
src/Core/Modules/Backend/AreaList.php
AreaList.Init
protected function Init() { $this->layout = new Layout(Request::GetData('layout')); if (!$this->layout->Exists()) { Response::Redirect(BackendRouter::ModuleUrl(new LayoutList())); return true; } $this->listProvider = new AreaListProvider($this->layout); $this->area = $this->listProvider->TopMost(); $this->hasAreas = (bool) $this->area; return parent::Init(); }
php
protected function Init() { $this->layout = new Layout(Request::GetData('layout')); if (!$this->layout->Exists()) { Response::Redirect(BackendRouter::ModuleUrl(new LayoutList())); return true; } $this->listProvider = new AreaListProvider($this->layout); $this->area = $this->listProvider->TopMost(); $this->hasAreas = (bool) $this->area; return parent::Init(); }
[ "protected", "function", "Init", "(", ")", "{", "$", "this", "->", "layout", "=", "new", "Layout", "(", "Request", "::", "GetData", "(", "'layout'", ")", ")", ";", "if", "(", "!", "$", "this", "->", "layout", "->", "Exists", "(", ")", ")", "{", "Response", "::", "Redirect", "(", "BackendRouter", "::", "ModuleUrl", "(", "new", "LayoutList", "(", ")", ")", ")", ";", "return", "true", ";", "}", "$", "this", "->", "listProvider", "=", "new", "AreaListProvider", "(", "$", "this", "->", "layout", ")", ";", "$", "this", "->", "area", "=", "$", "this", "->", "listProvider", "->", "TopMost", "(", ")", ";", "$", "this", "->", "hasAreas", "=", "(", "bool", ")", "$", "this", "->", "area", ";", "return", "parent", "::", "Init", "(", ")", ";", "}" ]
Initializes the list @return boolean
[ "Initializes", "the", "list" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaList.php#L49-L62
train
agentmedia/phine-core
src/Core/Modules/Backend/AreaList.php
AreaList.CreateAfterUrl
protected function CreateAfterUrl(Area $area) { $args = array('layout'=>$this->layout->GetID()); $args['previous'] = $area->GetID(); return BackendRouter::ModuleUrl(new AreaForm(), $args); }
php
protected function CreateAfterUrl(Area $area) { $args = array('layout'=>$this->layout->GetID()); $args['previous'] = $area->GetID(); return BackendRouter::ModuleUrl(new AreaForm(), $args); }
[ "protected", "function", "CreateAfterUrl", "(", "Area", "$", "area", ")", "{", "$", "args", "=", "array", "(", "'layout'", "=>", "$", "this", "->", "layout", "->", "GetID", "(", ")", ")", ";", "$", "args", "[", "'previous'", "]", "=", "$", "area", "->", "GetID", "(", ")", ";", "return", "BackendRouter", "::", "ModuleUrl", "(", "new", "AreaForm", "(", ")", ",", "$", "args", ")", ";", "}" ]
The create url for an area after another @param Area $area @return string
[ "The", "create", "url", "for", "an", "area", "after", "another" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaList.php#L78-L83
train
agentmedia/phine-core
src/Core/Modules/Backend/AreaList.php
AreaList.NextArea
protected function NextArea() { $area = $this->area; $this->area = $this->listProvider->NextOf($this->area); return $area; }
php
protected function NextArea() { $area = $this->area; $this->area = $this->listProvider->NextOf($this->area); return $area; }
[ "protected", "function", "NextArea", "(", ")", "{", "$", "area", "=", "$", "this", "->", "area", ";", "$", "this", "->", "area", "=", "$", "this", "->", "listProvider", "->", "NextOf", "(", "$", "this", "->", "area", ")", ";", "return", "$", "area", ";", "}" ]
Gets the next area @return Area
[ "Gets", "the", "next", "area" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaList.php#L110-L115
train
agentmedia/phine-core
src/Core/Modules/Backend/AreaList.php
AreaList.CanEdit
protected function CanEdit(Area $area) { return self::Guard()->Allow(BackendAction::Edit(), $area) && self::Guard()->Allow(BackendAction::UseIt(), new AreaForm()); }
php
protected function CanEdit(Area $area) { return self::Guard()->Allow(BackendAction::Edit(), $area) && self::Guard()->Allow(BackendAction::UseIt(), new AreaForm()); }
[ "protected", "function", "CanEdit", "(", "Area", "$", "area", ")", "{", "return", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Edit", "(", ")", ",", "$", "area", ")", "&&", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "UseIt", "(", ")", ",", "new", "AreaForm", "(", ")", ")", ";", "}" ]
True if area can be edited @param Area $area @return bool Returns true if the area can be edited
[ "True", "if", "area", "can", "be", "edited" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/AreaList.php#L141-L145
train
devlabmtl/haven-cms
Entity/BasePage.php
BasePage.addBlogContent
public function addBlogContent(\Haven\CmsBundle\Entity\PageContent $pageContents) { $this->addPageContent($pageContents); return $this; }
php
public function addBlogContent(\Haven\CmsBundle\Entity\PageContent $pageContents) { $this->addPageContent($pageContents); return $this; }
[ "public", "function", "addBlogContent", "(", "\\", "Haven", "\\", "CmsBundle", "\\", "Entity", "\\", "PageContent", "$", "pageContents", ")", "{", "$", "this", "->", "addPageContent", "(", "$", "pageContents", ")", ";", "return", "$", "this", ";", "}" ]
Add page_contents for blogcontent type @param \Haven\CmsBundle\Entity\PageContent $pageContents @return Page
[ "Add", "page_contents", "for", "blogcontent", "type" ]
c20761a07c201a966dbda1f3eae33617f80e1ece
https://github.com/devlabmtl/haven-cms/blob/c20761a07c201a966dbda1f3eae33617f80e1ece/Entity/BasePage.php#L190-L195
train
devlabmtl/haven-cms
Entity/BasePage.php
BasePage.addBusCardContent
public function addBusCardContent(\Haven\CmsBundle\Entity\PageContent $pageContents) { $this->addPageContent($pageContents); return $this; }
php
public function addBusCardContent(\Haven\CmsBundle\Entity\PageContent $pageContents) { $this->addPageContent($pageContents); return $this; }
[ "public", "function", "addBusCardContent", "(", "\\", "Haven", "\\", "CmsBundle", "\\", "Entity", "\\", "PageContent", "$", "pageContents", ")", "{", "$", "this", "->", "addPageContent", "(", "$", "pageContents", ")", ";", "return", "$", "this", ";", "}" ]
Add page_contents for buscardcontent type @param \Haven\CmsBundle\Entity\PageContent $pageContents @return Page
[ "Add", "page_contents", "for", "buscardcontent", "type" ]
c20761a07c201a966dbda1f3eae33617f80e1ece
https://github.com/devlabmtl/haven-cms/blob/c20761a07c201a966dbda1f3eae33617f80e1ece/Entity/BasePage.php#L225-L230
train
devlabmtl/haven-cms
Entity/BasePage.php
BasePage.addEnterpriseContent
public function addEnterpriseContent(\Haven\CmsBundle\Entity\PageContent $pageContents) { $this->addPageContent($pageContents); return $this; }
php
public function addEnterpriseContent(\Haven\CmsBundle\Entity\PageContent $pageContents) { $this->addPageContent($pageContents); return $this; }
[ "public", "function", "addEnterpriseContent", "(", "\\", "Haven", "\\", "CmsBundle", "\\", "Entity", "\\", "PageContent", "$", "pageContents", ")", "{", "$", "this", "->", "addPageContent", "(", "$", "pageContents", ")", ";", "return", "$", "this", ";", "}" ]
Add page_contents for enterprisecontent type @param \Haven\CmsBundle\Entity\PageContent $pageContents @return Page
[ "Add", "page_contents", "for", "enterprisecontent", "type" ]
c20761a07c201a966dbda1f3eae33617f80e1ece
https://github.com/devlabmtl/haven-cms/blob/c20761a07c201a966dbda1f3eae33617f80e1ece/Entity/BasePage.php#L260-L265
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.setSchema
public function setSchema(Schema $schema) { $this->schema = $schema; if (!$this->getSchema()->hasTable($this->getName())) { $this->getSchema()->addTable($this); } }
php
public function setSchema(Schema $schema) { $this->schema = $schema; if (!$this->getSchema()->hasTable($this->getName())) { $this->getSchema()->addTable($this); } }
[ "public", "function", "setSchema", "(", "Schema", "$", "schema", ")", "{", "$", "this", "->", "schema", "=", "$", "schema", ";", "if", "(", "!", "$", "this", "->", "getSchema", "(", ")", "->", "hasTable", "(", "$", "this", "->", "getName", "(", ")", ")", ")", "{", "$", "this", "->", "getSchema", "(", ")", "->", "addTable", "(", "$", "this", ")", ";", "}", "}" ]
Sets the table schema. @param \Fridge\DBAL\Schema\Schema $schema The table schema.
[ "Sets", "the", "table", "schema", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L98-L105
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.createColumn
public function createColumn($name, $type, array $properties = array()) { if (is_string($type)) { $type = Type::getType($type); } $column = new Column($name, $type, $properties); $this->addColumn($column); return $column; }
php
public function createColumn($name, $type, array $properties = array()) { if (is_string($type)) { $type = Type::getType($type); } $column = new Column($name, $type, $properties); $this->addColumn($column); return $column; }
[ "public", "function", "createColumn", "(", "$", "name", ",", "$", "type", ",", "array", "$", "properties", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", "type", ")", ")", "{", "$", "type", "=", "Type", "::", "getType", "(", "$", "type", ")", ";", "}", "$", "column", "=", "new", "Column", "(", "$", "name", ",", "$", "type", ",", "$", "properties", ")", ";", "$", "this", "->", "addColumn", "(", "$", "column", ")", ";", "return", "$", "column", ";", "}" ]
Creates and adds a new column. @param string $name The column name. @param string|\Fridge\DBAL\Type\TypeInterface $type The column type. @param array $properties The column properties. @return \Fridge\DBAL\Schema\Column The new column.
[ "Creates", "and", "adds", "a", "new", "column", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L116-L126
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.getColumn
public function getColumn($name) { if (!$this->hasColumn($name)) { throw SchemaException::tableColumnDoesNotExist($this->getName(), $name); } return $this->columns[$name]; }
php
public function getColumn($name) { if (!$this->hasColumn($name)) { throw SchemaException::tableColumnDoesNotExist($this->getName(), $name); } return $this->columns[$name]; }
[ "public", "function", "getColumn", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasColumn", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableColumnDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "columns", "[", "$", "name", "]", ";", "}" ]
Gets a table column. @param string $name The table column name. @throws \Fridge\DBAL\Exception\SchemaException If the column does not exist. @return \Fridge\DBAL\Schema\Column The table column.
[ "Gets", "a", "table", "column", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L183-L190
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.dropColumn
public function dropColumn($name) { if (!$this->hasColumn($name)) { throw SchemaException::tableColumnDoesNotExist($this->getName(), $name); } unset($this->columns[$name]); }
php
public function dropColumn($name) { if (!$this->hasColumn($name)) { throw SchemaException::tableColumnDoesNotExist($this->getName(), $name); } unset($this->columns[$name]); }
[ "public", "function", "dropColumn", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasColumn", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableColumnDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "columns", "[", "$", "name", "]", ")", ";", "}" ]
Drops a column. @param string $name The column name. @throws \Fridge\DBAL\Exception\SchemaException If the column does not exist.
[ "Drops", "a", "column", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L239-L246
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.createPrimaryKey
public function createPrimaryKey(array $columnNames, $name = null) { if ($this->hasPrimaryKey()) { throw SchemaException::tablePrimaryKeyAlreadyExists($this->getName()); } $primaryKey = new PrimaryKey($name, $columnNames); $this->setPrimaryKey($primaryKey); $this->createIndex($columnNames, true, $primaryKey->getName()); return $primaryKey; }
php
public function createPrimaryKey(array $columnNames, $name = null) { if ($this->hasPrimaryKey()) { throw SchemaException::tablePrimaryKeyAlreadyExists($this->getName()); } $primaryKey = new PrimaryKey($name, $columnNames); $this->setPrimaryKey($primaryKey); $this->createIndex($columnNames, true, $primaryKey->getName()); return $primaryKey; }
[ "public", "function", "createPrimaryKey", "(", "array", "$", "columnNames", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasPrimaryKey", "(", ")", ")", "{", "throw", "SchemaException", "::", "tablePrimaryKeyAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "primaryKey", "=", "new", "PrimaryKey", "(", "$", "name", ",", "$", "columnNames", ")", ";", "$", "this", "->", "setPrimaryKey", "(", "$", "primaryKey", ")", ";", "$", "this", "->", "createIndex", "(", "$", "columnNames", ",", "true", ",", "$", "primaryKey", "->", "getName", "(", ")", ")", ";", "return", "$", "primaryKey", ";", "}" ]
Creates and adds a new primary key. @param array $columnNames The primary key column names. @param string $name The primary key name. @throws \Fridge\DBAL\Exception\SchemaException If a primary key already exists. @return \Fridge\DBAL\Schema\PrimaryKey The new primary key.
[ "Creates", "and", "adds", "a", "new", "primary", "key", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L258-L270
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.setPrimaryKey
public function setPrimaryKey(PrimaryKey $primaryKey) { foreach ($primaryKey->getColumnNames() as $columnName) { $this->getColumn($columnName)->setNotNull(true); } $this->primaryKey = $primaryKey; }
php
public function setPrimaryKey(PrimaryKey $primaryKey) { foreach ($primaryKey->getColumnNames() as $columnName) { $this->getColumn($columnName)->setNotNull(true); } $this->primaryKey = $primaryKey; }
[ "public", "function", "setPrimaryKey", "(", "PrimaryKey", "$", "primaryKey", ")", "{", "foreach", "(", "$", "primaryKey", "->", "getColumnNames", "(", ")", "as", "$", "columnName", ")", "{", "$", "this", "->", "getColumn", "(", "$", "columnName", ")", "->", "setNotNull", "(", "true", ")", ";", "}", "$", "this", "->", "primaryKey", "=", "$", "primaryKey", ";", "}" ]
Sets the table primery key. @param \Fridge\DBAL\Schema\PrimaryKey $primaryKey The table primary key.
[ "Sets", "the", "table", "primery", "key", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L297-L304
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.dropPrimaryKey
public function dropPrimaryKey() { if (!$this->hasPrimaryKey()) { throw SchemaException::tablePrimaryKeyDoesNotExist($this->getName()); } foreach ($this->getIndexes() as $index) { if ($index->hasSameColumnNames($this->getPrimaryKey()->getColumnNames())) { $this->dropIndex($index->getName()); } } $this->primaryKey = null; }
php
public function dropPrimaryKey() { if (!$this->hasPrimaryKey()) { throw SchemaException::tablePrimaryKeyDoesNotExist($this->getName()); } foreach ($this->getIndexes() as $index) { if ($index->hasSameColumnNames($this->getPrimaryKey()->getColumnNames())) { $this->dropIndex($index->getName()); } } $this->primaryKey = null; }
[ "public", "function", "dropPrimaryKey", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasPrimaryKey", "(", ")", ")", "{", "throw", "SchemaException", "::", "tablePrimaryKeyDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "getIndexes", "(", ")", "as", "$", "index", ")", "{", "if", "(", "$", "index", "->", "hasSameColumnNames", "(", "$", "this", "->", "getPrimaryKey", "(", ")", "->", "getColumnNames", "(", ")", ")", ")", "{", "$", "this", "->", "dropIndex", "(", "$", "index", "->", "getName", "(", ")", ")", ";", "}", "}", "$", "this", "->", "primaryKey", "=", "null", ";", "}" ]
Drops the table primary key. @throws \Fridge\DBAL\Exception\SchemaException If there is no primary key.
[ "Drops", "the", "table", "primary", "key", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L311-L324
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.createForeignKey
public function createForeignKey( array $localColumnNames, $foreignTable, array $foreignColumnNames, $onDelete = ForeignKey::RESTRICT, $onUpdate = ForeignKey::RESTRICT, $name = null ) { if ($foreignTable instanceof Table) { $foreignTable = $foreignTable->getName(); } $foreignKey = new ForeignKey( $name, $localColumnNames, $foreignTable, $foreignColumnNames, $onDelete, $onUpdate ); $this->addForeignKey($foreignKey); $this->createIndex($localColumnNames, false, 'idx_'.$foreignKey->getName()); return $foreignKey; }
php
public function createForeignKey( array $localColumnNames, $foreignTable, array $foreignColumnNames, $onDelete = ForeignKey::RESTRICT, $onUpdate = ForeignKey::RESTRICT, $name = null ) { if ($foreignTable instanceof Table) { $foreignTable = $foreignTable->getName(); } $foreignKey = new ForeignKey( $name, $localColumnNames, $foreignTable, $foreignColumnNames, $onDelete, $onUpdate ); $this->addForeignKey($foreignKey); $this->createIndex($localColumnNames, false, 'idx_'.$foreignKey->getName()); return $foreignKey; }
[ "public", "function", "createForeignKey", "(", "array", "$", "localColumnNames", ",", "$", "foreignTable", ",", "array", "$", "foreignColumnNames", ",", "$", "onDelete", "=", "ForeignKey", "::", "RESTRICT", ",", "$", "onUpdate", "=", "ForeignKey", "::", "RESTRICT", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "foreignTable", "instanceof", "Table", ")", "{", "$", "foreignTable", "=", "$", "foreignTable", "->", "getName", "(", ")", ";", "}", "$", "foreignKey", "=", "new", "ForeignKey", "(", "$", "name", ",", "$", "localColumnNames", ",", "$", "foreignTable", ",", "$", "foreignColumnNames", ",", "$", "onDelete", ",", "$", "onUpdate", ")", ";", "$", "this", "->", "addForeignKey", "(", "$", "foreignKey", ")", ";", "$", "this", "->", "createIndex", "(", "$", "localColumnNames", ",", "false", ",", "'idx_'", ".", "$", "foreignKey", "->", "getName", "(", ")", ")", ";", "return", "$", "foreignKey", ";", "}" ]
Creates and adds a new foreign key. @param array $localColumnNames The foreign key local column names. @param string|\Fridge\DBAL\Schema\Table $foreignTable The foreign key foreign table. @param array $foreignColumnNames The foreign key foreign column names. @param string $onDelete The foreign key referential on delete action. @param string $onUpdate the foreign key referential on update action. @param string $name The foreign key name. @return \Fridge\DBAL\Schema\ForeignKey The new foreign key.
[ "Creates", "and", "adds", "a", "new", "foreign", "key", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L338-L364
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.setForeignKeys
public function setForeignKeys(array $foreignKeys) { $this->foreignKeys = array(); foreach ($foreignKeys as $foreignKey) { $this->addForeignKey($foreignKey); } }
php
public function setForeignKeys(array $foreignKeys) { $this->foreignKeys = array(); foreach ($foreignKeys as $foreignKey) { $this->addForeignKey($foreignKey); } }
[ "public", "function", "setForeignKeys", "(", "array", "$", "foreignKeys", ")", "{", "$", "this", "->", "foreignKeys", "=", "array", "(", ")", ";", "foreach", "(", "$", "foreignKeys", "as", "$", "foreignKey", ")", "{", "$", "this", "->", "addForeignKey", "(", "$", "foreignKey", ")", ";", "}", "}" ]
Sets the table foreign keys. @param array $foreignKeys The table foreign keys.
[ "Sets", "the", "table", "foreign", "keys", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L391-L398
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.getForeignKey
public function getForeignKey($name) { if (!$this->hasForeignKey($name)) { throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $name); } return $this->foreignKeys[$name]; }
php
public function getForeignKey($name) { if (!$this->hasForeignKey($name)) { throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $name); } return $this->foreignKeys[$name]; }
[ "public", "function", "getForeignKey", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasForeignKey", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableForeignKeyDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "foreignKeys", "[", "$", "name", "]", ";", "}" ]
Gets a foreign key @param string $name The foreign key name. @throws \Fridge\DBAL\Exception\SchemaException If the foreign key does not exist. @return \Fridge\DBAL\Schema\ForeignKey The foreign key.
[ "Gets", "a", "foreign", "key" ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L421-L428
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.addForeignKey
public function addForeignKey(ForeignKey $foreignKey) { if ($this->hasForeignKey($foreignKey->getName())) { throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $foreignKey->getName()); } foreach ($foreignKey->getLocalColumnNames() as $columnName) { if (!$this->hasColumn($columnName)) { throw SchemaException::tableColumnDoesNotExist($this->getName(), $columnName); } } if ($this->hasSchema()) { foreach ($foreignKey->getForeignColumnNames() as $columnName) { if (!$this->getSchema()->getTable($foreignKey->getForeignTableName())->hasColumn($columnName)) { throw SchemaException::tableColumnDoesNotExist($foreignKey->getForeignTableName(), $columnName); } } } $this->foreignKeys[$foreignKey->getName()] = $foreignKey; }
php
public function addForeignKey(ForeignKey $foreignKey) { if ($this->hasForeignKey($foreignKey->getName())) { throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $foreignKey->getName()); } foreach ($foreignKey->getLocalColumnNames() as $columnName) { if (!$this->hasColumn($columnName)) { throw SchemaException::tableColumnDoesNotExist($this->getName(), $columnName); } } if ($this->hasSchema()) { foreach ($foreignKey->getForeignColumnNames() as $columnName) { if (!$this->getSchema()->getTable($foreignKey->getForeignTableName())->hasColumn($columnName)) { throw SchemaException::tableColumnDoesNotExist($foreignKey->getForeignTableName(), $columnName); } } } $this->foreignKeys[$foreignKey->getName()] = $foreignKey; }
[ "public", "function", "addForeignKey", "(", "ForeignKey", "$", "foreignKey", ")", "{", "if", "(", "$", "this", "->", "hasForeignKey", "(", "$", "foreignKey", "->", "getName", "(", ")", ")", ")", "{", "throw", "SchemaException", "::", "tableForeignKeyAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "foreignKey", "->", "getName", "(", ")", ")", ";", "}", "foreach", "(", "$", "foreignKey", "->", "getLocalColumnNames", "(", ")", "as", "$", "columnName", ")", "{", "if", "(", "!", "$", "this", "->", "hasColumn", "(", "$", "columnName", ")", ")", "{", "throw", "SchemaException", "::", "tableColumnDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "columnName", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasSchema", "(", ")", ")", "{", "foreach", "(", "$", "foreignKey", "->", "getForeignColumnNames", "(", ")", "as", "$", "columnName", ")", "{", "if", "(", "!", "$", "this", "->", "getSchema", "(", ")", "->", "getTable", "(", "$", "foreignKey", "->", "getForeignTableName", "(", ")", ")", "->", "hasColumn", "(", "$", "columnName", ")", ")", "{", "throw", "SchemaException", "::", "tableColumnDoesNotExist", "(", "$", "foreignKey", "->", "getForeignTableName", "(", ")", ",", "$", "columnName", ")", ";", "}", "}", "}", "$", "this", "->", "foreignKeys", "[", "$", "foreignKey", "->", "getName", "(", ")", "]", "=", "$", "foreignKey", ";", "}" ]
Adds a foreign key to the table. @param \Fridge\DBAL\Schema\ForeignKey $foreignKey The foreign key to add. @throws \Fridge\DBAL\Exception\SchemaException If the foreign key already exist, if a local column does not exist or if a foreign column does not exist.
[ "Adds", "a", "foreign", "key", "to", "the", "table", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L438-L459
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.renameForeignKey
public function renameForeignKey($oldName, $newName) { if (!$this->hasForeignKey($oldName)) { throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $oldName); } if ($this->hasForeignKey($newName)) { throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $newName); } $this->foreignKeys[$oldName]->setName($newName); $this->foreignKeys[$newName] = $this->foreignKeys[$oldName]; unset($this->foreignKeys[$oldName]); }
php
public function renameForeignKey($oldName, $newName) { if (!$this->hasForeignKey($oldName)) { throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $oldName); } if ($this->hasForeignKey($newName)) { throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $newName); } $this->foreignKeys[$oldName]->setName($newName); $this->foreignKeys[$newName] = $this->foreignKeys[$oldName]; unset($this->foreignKeys[$oldName]); }
[ "public", "function", "renameForeignKey", "(", "$", "oldName", ",", "$", "newName", ")", "{", "if", "(", "!", "$", "this", "->", "hasForeignKey", "(", "$", "oldName", ")", ")", "{", "throw", "SchemaException", "::", "tableForeignKeyDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "oldName", ")", ";", "}", "if", "(", "$", "this", "->", "hasForeignKey", "(", "$", "newName", ")", ")", "{", "throw", "SchemaException", "::", "tableForeignKeyAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "newName", ")", ";", "}", "$", "this", "->", "foreignKeys", "[", "$", "oldName", "]", "->", "setName", "(", "$", "newName", ")", ";", "$", "this", "->", "foreignKeys", "[", "$", "newName", "]", "=", "$", "this", "->", "foreignKeys", "[", "$", "oldName", "]", ";", "unset", "(", "$", "this", "->", "foreignKeys", "[", "$", "oldName", "]", ")", ";", "}" ]
Renames a foreign key. @param string $oldName The old foreign key name. @param string $newName The new foreign key name. @throws \Fridge\DBAL\Exception\SchemaException If the old foreign key does not exist or if the new foreign key already exists.
[ "Renames", "a", "foreign", "key", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L470-L483
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.dropForeignKey
public function dropForeignKey($name) { if (!$this->hasForeignKey($name)) { throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $name); } unset($this->foreignKeys[$name]); }
php
public function dropForeignKey($name) { if (!$this->hasForeignKey($name)) { throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $name); } unset($this->foreignKeys[$name]); }
[ "public", "function", "dropForeignKey", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasForeignKey", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableForeignKeyDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "foreignKeys", "[", "$", "name", "]", ")", ";", "}" ]
Drops a foreign key. @param string $name The foreign key name. @throws \Fridge\DBAL\Exception\SchemaException If the foreign key does not exist.
[ "Drops", "a", "foreign", "key", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L492-L499
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.createIndex
public function createIndex(array $columnNames, $unique = false, $name = null) { $index = new Index($name, $columnNames, $unique); $this->addIndex($index); return $index; }
php
public function createIndex(array $columnNames, $unique = false, $name = null) { $index = new Index($name, $columnNames, $unique); $this->addIndex($index); return $index; }
[ "public", "function", "createIndex", "(", "array", "$", "columnNames", ",", "$", "unique", "=", "false", ",", "$", "name", "=", "null", ")", "{", "$", "index", "=", "new", "Index", "(", "$", "name", ",", "$", "columnNames", ",", "$", "unique", ")", ";", "$", "this", "->", "addIndex", "(", "$", "index", ")", ";", "return", "$", "index", ";", "}" ]
Creates and adds a new index. @param array $columnNames The index column names. @param boolean $unique TRUE if the index is unique else FALSE. @param string $name The index name. @return \Fridge\DBAL\Schema\Index The new index.
[ "Creates", "and", "adds", "a", "new", "index", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L510-L516
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.setIndexes
public function setIndexes(array $indexes) { $this->indexes = array(); foreach ($indexes as $index) { $this->addIndex($index); } }
php
public function setIndexes(array $indexes) { $this->indexes = array(); foreach ($indexes as $index) { $this->addIndex($index); } }
[ "public", "function", "setIndexes", "(", "array", "$", "indexes", ")", "{", "$", "this", "->", "indexes", "=", "array", "(", ")", ";", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "$", "this", "->", "addIndex", "(", "$", "index", ")", ";", "}", "}" ]
Sets the table indexes. @param array $indexes The table indexes.
[ "Sets", "the", "table", "indexes", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L543-L550
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.getIndex
public function getIndex($name) { if (!$this->hasIndex($name)) { throw SchemaException::tableIndexDoesNotExist($this->getName(), $name); } return $this->indexes[$name]; }
php
public function getIndex($name) { if (!$this->hasIndex($name)) { throw SchemaException::tableIndexDoesNotExist($this->getName(), $name); } return $this->indexes[$name]; }
[ "public", "function", "getIndex", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasIndex", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableIndexDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "indexes", "[", "$", "name", "]", ";", "}" ]
Gets a table index. @param string $name The table index name. @throws \Fridge\DBAL\Exception\SchemaException If the index does not exist. @return \Fridge\DBAL\Schema\Index The table index.
[ "Gets", "a", "table", "index", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L595-L602
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.dropIndex
public function dropIndex($name) { if (!$this->hasIndex($name)) { throw SchemaException::tableIndexDoesNotExist($this->getName(), $name); } unset($this->indexes[$name]); }
php
public function dropIndex($name) { if (!$this->hasIndex($name)) { throw SchemaException::tableIndexDoesNotExist($this->getName(), $name); } unset($this->indexes[$name]); }
[ "public", "function", "dropIndex", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasIndex", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableIndexDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "indexes", "[", "$", "name", "]", ")", ";", "}" ]
Drops an index. @param string $name The index name. @throws \Fridge\DBAL\Exception\SchemaException If the index does not exist.
[ "Drops", "an", "index", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L669-L676
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.createCheck
public function createCheck($constraint, $name = null) { $check = new Check($name, $constraint); $this->addCheck($check); return $check; }
php
public function createCheck($constraint, $name = null) { $check = new Check($name, $constraint); $this->addCheck($check); return $check; }
[ "public", "function", "createCheck", "(", "$", "constraint", ",", "$", "name", "=", "null", ")", "{", "$", "check", "=", "new", "Check", "(", "$", "name", ",", "$", "constraint", ")", ";", "$", "this", "->", "addCheck", "(", "$", "check", ")", ";", "return", "$", "check", ";", "}" ]
Creates and adds a new check. @param string $constraint The check constraint. @param string $name The check name. @return \Fridge\DBAL\Schema\Check The new index.
[ "Creates", "and", "adds", "a", "new", "check", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L686-L692
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.setChecks
public function setChecks(array $checks) { $this->checks = array(); foreach ($checks as $check) { $this->addCheck($check); } }
php
public function setChecks(array $checks) { $this->checks = array(); foreach ($checks as $check) { $this->addCheck($check); } }
[ "public", "function", "setChecks", "(", "array", "$", "checks", ")", "{", "$", "this", "->", "checks", "=", "array", "(", ")", ";", "foreach", "(", "$", "checks", "as", "$", "check", ")", "{", "$", "this", "->", "addCheck", "(", "$", "check", ")", ";", "}", "}" ]
Sets the table chekcs. @param array $checks The table checks.
[ "Sets", "the", "table", "chekcs", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L719-L726
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.getCheck
public function getCheck($name) { if (!$this->hasCheck($name)) { throw SchemaException::tableCheckDoesNotExist($this->getName(), $name); } return $this->checks[$name]; }
php
public function getCheck($name) { if (!$this->hasCheck($name)) { throw SchemaException::tableCheckDoesNotExist($this->getName(), $name); } return $this->checks[$name]; }
[ "public", "function", "getCheck", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasCheck", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableCheckDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "checks", "[", "$", "name", "]", ";", "}" ]
Gets a table check. @param string $name The table check name. @throws \Fridge\DBAL\Exception\SchemaException If the check does not exist. @return \Fridge\DBAL\Schema\Check The table check.
[ "Gets", "a", "table", "check", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L749-L756
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.addCheck
public function addCheck(Check $check) { if ($this->hasCheck($check->getName())) { throw SchemaException::tableCheckAlreadyExists($this->getName(), $check->getName()); } $this->checks[$check->getName()] = $check; }
php
public function addCheck(Check $check) { if ($this->hasCheck($check->getName())) { throw SchemaException::tableCheckAlreadyExists($this->getName(), $check->getName()); } $this->checks[$check->getName()] = $check; }
[ "public", "function", "addCheck", "(", "Check", "$", "check", ")", "{", "if", "(", "$", "this", "->", "hasCheck", "(", "$", "check", "->", "getName", "(", ")", ")", ")", "{", "throw", "SchemaException", "::", "tableCheckAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "check", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "checks", "[", "$", "check", "->", "getName", "(", ")", "]", "=", "$", "check", ";", "}" ]
Adds a check to the table. @param \Fridge\DBAL\Schema\Check $check The check to add. @throws \Fridge\DBAL\Exception\SchemaException If the check already exists.
[ "Adds", "a", "check", "to", "the", "table", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L765-L772
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.renameCheck
public function renameCheck($oldName, $newName) { if (!$this->hasCheck($oldName)) { throw SchemaException::tableCheckDoesNotExist($this->getName(), $oldName); } if ($this->hasCheck($newName)) { throw SchemaException::tableCheckAlreadyExists($this->getName(), $newName); } $this->checks[$oldName]->setName($newName); $this->checks[$newName] = $this->checks[$oldName]; unset($this->checks[$oldName]); }
php
public function renameCheck($oldName, $newName) { if (!$this->hasCheck($oldName)) { throw SchemaException::tableCheckDoesNotExist($this->getName(), $oldName); } if ($this->hasCheck($newName)) { throw SchemaException::tableCheckAlreadyExists($this->getName(), $newName); } $this->checks[$oldName]->setName($newName); $this->checks[$newName] = $this->checks[$oldName]; unset($this->checks[$oldName]); }
[ "public", "function", "renameCheck", "(", "$", "oldName", ",", "$", "newName", ")", "{", "if", "(", "!", "$", "this", "->", "hasCheck", "(", "$", "oldName", ")", ")", "{", "throw", "SchemaException", "::", "tableCheckDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "oldName", ")", ";", "}", "if", "(", "$", "this", "->", "hasCheck", "(", "$", "newName", ")", ")", "{", "throw", "SchemaException", "::", "tableCheckAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "newName", ")", ";", "}", "$", "this", "->", "checks", "[", "$", "oldName", "]", "->", "setName", "(", "$", "newName", ")", ";", "$", "this", "->", "checks", "[", "$", "newName", "]", "=", "$", "this", "->", "checks", "[", "$", "oldName", "]", ";", "unset", "(", "$", "this", "->", "checks", "[", "$", "oldName", "]", ")", ";", "}" ]
Renames a check. @param string $oldName The old check name. @param string $newName The new check name. @throws \Fridge\DBAL\Exception\SchemaException If the old check does not exist or if the new check already exists.
[ "Renames", "a", "check", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L783-L796
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Table.php
Table.dropCheck
public function dropCheck($name) { if (!$this->hasCheck($name)) { throw SchemaException::tableCheckDoesNotExist($this->getName(), $name); } unset($this->checks[$name]); }
php
public function dropCheck($name) { if (!$this->hasCheck($name)) { throw SchemaException::tableCheckDoesNotExist($this->getName(), $name); } unset($this->checks[$name]); }
[ "public", "function", "dropCheck", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasCheck", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "tableCheckDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "checks", "[", "$", "name", "]", ")", ";", "}" ]
Drops a check. @param string $name The check name. @throws \Fridge\DBAL\Exception\SchemaException If the check does not exist.
[ "Drops", "a", "check", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Table.php#L805-L812
train
Subscribo/klarna-invoice-sdk-wrapped
src/CheckoutServiceRequest.php
CheckoutServiceRequest.getHeaders
public function getHeaders() { $digest = Klarna::digest( Klarna::colon( $this->config['eid'], $this->params['currency'], $this->config['secret'] ) ); return array( "Accept: {$this->accept}", "Authorization: xmlrpc-4.2 {$digest}" ); }
php
public function getHeaders() { $digest = Klarna::digest( Klarna::colon( $this->config['eid'], $this->params['currency'], $this->config['secret'] ) ); return array( "Accept: {$this->accept}", "Authorization: xmlrpc-4.2 {$digest}" ); }
[ "public", "function", "getHeaders", "(", ")", "{", "$", "digest", "=", "Klarna", "::", "digest", "(", "Klarna", "::", "colon", "(", "$", "this", "->", "config", "[", "'eid'", "]", ",", "$", "this", "->", "params", "[", "'currency'", "]", ",", "$", "this", "->", "config", "[", "'secret'", "]", ")", ")", ";", "return", "array", "(", "\"Accept: {$this->accept}\"", ",", "\"Authorization: xmlrpc-4.2 {$digest}\"", ")", ";", "}" ]
Get the headers associated to this request @return array Array of headers strings
[ "Get", "the", "headers", "associated", "to", "this", "request" ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/CheckoutServiceRequest.php#L91-L105
train
NigelGreenway/Demander
src/ViewModel/AbstractViewModel.php
AbstractViewModel.toArray
private function toArray() { $data = []; $reflection = new ReflectionClass($this); foreach ($reflection->getProperties() as $property) { $property->setAccessible(true); $data[$property->getName()] = $property->getValue($this); } return $data; }
php
private function toArray() { $data = []; $reflection = new ReflectionClass($this); foreach ($reflection->getProperties() as $property) { $property->setAccessible(true); $data[$property->getName()] = $property->getValue($this); } return $data; }
[ "private", "function", "toArray", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "this", ")", ";", "foreach", "(", "$", "reflection", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "data", "[", "$", "property", "->", "getName", "(", ")", "]", "=", "$", "property", "->", "getValue", "(", "$", "this", ")", ";", "}", "return", "$", "data", ";", "}" ]
Convert the ViewModel object to an array @return array
[ "Convert", "the", "ViewModel", "object", "to", "an", "array" ]
2481c2deb28c6d8da37b0155fa41dcd4627a979f
https://github.com/NigelGreenway/Demander/blob/2481c2deb28c6d8da37b0155fa41dcd4627a979f/src/ViewModel/AbstractViewModel.php#L38-L50
train
mtils/cmsable
src/Cmsable/Model/TreeModelManager.php
TreeModelManager.makeModel
protected function makeModel(TreeScope $scope){ $model = clone $this->treeModelPrototype; $model->setRootId($scope->getModelRootId()); $model->setPathPrefix($scope->getPathPrefix()); return $model; }
php
protected function makeModel(TreeScope $scope){ $model = clone $this->treeModelPrototype; $model->setRootId($scope->getModelRootId()); $model->setPathPrefix($scope->getPathPrefix()); return $model; }
[ "protected", "function", "makeModel", "(", "TreeScope", "$", "scope", ")", "{", "$", "model", "=", "clone", "$", "this", "->", "treeModelPrototype", ";", "$", "model", "->", "setRootId", "(", "$", "scope", "->", "getModelRootId", "(", ")", ")", ";", "$", "model", "->", "setPathPrefix", "(", "$", "scope", "->", "getPathPrefix", "(", ")", ")", ";", "return", "$", "model", ";", "}" ]
Make a sitetree model @param \Cmsable\Routing\TreeScope\TreeScope $scope @return \Cmsable\Model\SiteTreeModelInterface
[ "Make", "a", "sitetree", "model" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Model/TreeModelManager.php#L77-L85
train
eureka-framework/component-config
src/Config/EmptyParser.php
EmptyParser.dump
public function dump($file, $content) { $fileWrited = file_put_contents($file, '<?php return ' . var_export($content, true) . ';'); if ($fileWrited === false) { throw new \Exception('Unable to dump data into php file !'); } }
php
public function dump($file, $content) { $fileWrited = file_put_contents($file, '<?php return ' . var_export($content, true) . ';'); if ($fileWrited === false) { throw new \Exception('Unable to dump data into php file !'); } }
[ "public", "function", "dump", "(", "$", "file", ",", "$", "content", ")", "{", "$", "fileWrited", "=", "file_put_contents", "(", "$", "file", ",", "'<?php return '", ".", "var_export", "(", "$", "content", ",", "true", ")", ".", "';'", ")", ";", "if", "(", "$", "fileWrited", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to dump data into php file !'", ")", ";", "}", "}" ]
Dump data into php file. @param string $file @param mixed $content @throws \Exception
[ "Dump", "data", "into", "php", "file", "." ]
ae3f17683fb3e96641b65375c6cca6a3139ae85e
https://github.com/eureka-framework/component-config/blob/ae3f17683fb3e96641b65375c6cca6a3139ae85e/src/Config/EmptyParser.php#L44-L51
train
OxfordInfoLabs/kinikit-core
src/Object/AssociativeArray.php
AssociativeArray.toArray
public function toArray($deep = true) { // Get each property $array = array(); foreach ($this->__getSerialisablePropertyMap() as $key => $value) { if ($value instanceof AssociativeArray) { $array[$key] = $deep ? $value->toArray() : $value; } else { $array[$key] = $value; } } return $array; }
php
public function toArray($deep = true) { // Get each property $array = array(); foreach ($this->__getSerialisablePropertyMap() as $key => $value) { if ($value instanceof AssociativeArray) { $array[$key] = $deep ? $value->toArray() : $value; } else { $array[$key] = $value; } } return $array; }
[ "public", "function", "toArray", "(", "$", "deep", "=", "true", ")", "{", "// Get each property", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "__getSerialisablePropertyMap", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "AssociativeArray", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "deep", "?", "$", "value", "->", "toArray", "(", ")", ":", "$", "value", ";", "}", "else", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "array", ";", "}" ]
Convert this into a regular php array.
[ "Convert", "this", "into", "a", "regular", "php", "array", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Object/AssociativeArray.php#L21-L34
train
OxfordInfoLabs/kinikit-core
src/Object/AssociativeArray.php
AssociativeArray.toAssociative
public static function toAssociative($array, $recursive = false) { $associative = new AssociativeArray(); foreach($array as $key => $value) { if ($recursive && is_array($value)) { $associative[$key] = self::toAssociative($value, true); } else { $associative[$key] = $value; } } return $associative; }
php
public static function toAssociative($array, $recursive = false) { $associative = new AssociativeArray(); foreach($array as $key => $value) { if ($recursive && is_array($value)) { $associative[$key] = self::toAssociative($value, true); } else { $associative[$key] = $value; } } return $associative; }
[ "public", "static", "function", "toAssociative", "(", "$", "array", ",", "$", "recursive", "=", "false", ")", "{", "$", "associative", "=", "new", "AssociativeArray", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "recursive", "&&", "is_array", "(", "$", "value", ")", ")", "{", "$", "associative", "[", "$", "key", "]", "=", "self", "::", "toAssociative", "(", "$", "value", ",", "true", ")", ";", "}", "else", "{", "$", "associative", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "associative", ";", "}" ]
Convert a regular array to an associative array. optionally recursive is required. @param $array @param bool $recursive
[ "Convert", "a", "regular", "array", "to", "an", "associative", "array", ".", "optionally", "recursive", "is", "required", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Object/AssociativeArray.php#L42-L55
train
fuelphp-storage/session
src/Driver/File.php
File.writeFile
protected function writeFile($payload) { // construct the session file name $file = $this->config['file']['path'].$this->config['file']['cookie_name'].'_'.$this->sessionId; // open the file if ( ! $handle = fopen($file,'c')) { throw new \Exception('Could not open the session file in "'.$this->config['file']['path']." for write access"); } // wait for a lock while ( ! flock($handle, LOCK_EX)); // erase existing contents ftruncate($handle, 0); // write the session data fwrite($handle, $payload); //release the lock flock($handle, LOCK_UN); // close the file fclose($handle); return true; }
php
protected function writeFile($payload) { // construct the session file name $file = $this->config['file']['path'].$this->config['file']['cookie_name'].'_'.$this->sessionId; // open the file if ( ! $handle = fopen($file,'c')) { throw new \Exception('Could not open the session file in "'.$this->config['file']['path']." for write access"); } // wait for a lock while ( ! flock($handle, LOCK_EX)); // erase existing contents ftruncate($handle, 0); // write the session data fwrite($handle, $payload); //release the lock flock($handle, LOCK_UN); // close the file fclose($handle); return true; }
[ "protected", "function", "writeFile", "(", "$", "payload", ")", "{", "// construct the session file name", "$", "file", "=", "$", "this", "->", "config", "[", "'file'", "]", "[", "'path'", "]", ".", "$", "this", "->", "config", "[", "'file'", "]", "[", "'cookie_name'", "]", ".", "'_'", ".", "$", "this", "->", "sessionId", ";", "// open the file", "if", "(", "!", "$", "handle", "=", "fopen", "(", "$", "file", ",", "'c'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Could not open the session file in \"'", ".", "$", "this", "->", "config", "[", "'file'", "]", "[", "'path'", "]", ".", "\" for write access\"", ")", ";", "}", "// wait for a lock", "while", "(", "!", "flock", "(", "$", "handle", ",", "LOCK_EX", ")", ")", ";", "// erase existing contents", "ftruncate", "(", "$", "handle", ",", "0", ")", ";", "// write the session data", "fwrite", "(", "$", "handle", ",", "$", "payload", ")", ";", "//release the lock", "flock", "(", "$", "handle", ",", "LOCK_UN", ")", ";", "// close the file", "fclose", "(", "$", "handle", ")", ";", "return", "true", ";", "}" ]
Writes the session file @return boolean
[ "Writes", "the", "session", "file" ]
948fd2b45286e65e7fababf65de89ca6aaca3c4a
https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/Driver/File.php#L232-L259
train
fuelphp-storage/session
src/Driver/File.php
File.readFile
protected function readFile() { // construct the session file name $file = $this->config['file']['path'].$this->config['file']['cookie_name'].'_'.$this->sessionId; if (is_file($file) and $handle = fopen($file,'r')) { // wait for a lock while ( ! flock($handle, LOCK_SH)); if ($size = filesize($file)) { // read the session data $payload = fread($handle, $size); } else { // file exists, but empty? $payload = false; } //release the lock flock($handle, LOCK_UN); // close the file fclose($handle); // return the loaded payload return $payload; } // session file did not exist or could not be opened return false; }
php
protected function readFile() { // construct the session file name $file = $this->config['file']['path'].$this->config['file']['cookie_name'].'_'.$this->sessionId; if (is_file($file) and $handle = fopen($file,'r')) { // wait for a lock while ( ! flock($handle, LOCK_SH)); if ($size = filesize($file)) { // read the session data $payload = fread($handle, $size); } else { // file exists, but empty? $payload = false; } //release the lock flock($handle, LOCK_UN); // close the file fclose($handle); // return the loaded payload return $payload; } // session file did not exist or could not be opened return false; }
[ "protected", "function", "readFile", "(", ")", "{", "// construct the session file name", "$", "file", "=", "$", "this", "->", "config", "[", "'file'", "]", "[", "'path'", "]", ".", "$", "this", "->", "config", "[", "'file'", "]", "[", "'cookie_name'", "]", ".", "'_'", ".", "$", "this", "->", "sessionId", ";", "if", "(", "is_file", "(", "$", "file", ")", "and", "$", "handle", "=", "fopen", "(", "$", "file", ",", "'r'", ")", ")", "{", "// wait for a lock", "while", "(", "!", "flock", "(", "$", "handle", ",", "LOCK_SH", ")", ")", ";", "if", "(", "$", "size", "=", "filesize", "(", "$", "file", ")", ")", "{", "// read the session data", "$", "payload", "=", "fread", "(", "$", "handle", ",", "$", "size", ")", ";", "}", "else", "{", "// file exists, but empty?", "$", "payload", "=", "false", ";", "}", "//release the lock", "flock", "(", "$", "handle", ",", "LOCK_UN", ")", ";", "// close the file", "fclose", "(", "$", "handle", ")", ";", "// return the loaded payload", "return", "$", "payload", ";", "}", "// session file did not exist or could not be opened", "return", "false", ";", "}" ]
Reads the session file @return string|boolean
[ "Reads", "the", "session", "file" ]
948fd2b45286e65e7fababf65de89ca6aaca3c4a
https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/Driver/File.php#L268-L301
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/xml/SimpleXMLExtended.php
SimpleXMLExtended.attribute
public function attribute($name) { $v = $this->attributes()->$name; if(!empty($v)) return (string)$v; }
php
public function attribute($name) { $v = $this->attributes()->$name; if(!empty($v)) return (string)$v; }
[ "public", "function", "attribute", "(", "$", "name", ")", "{", "$", "v", "=", "$", "this", "->", "attributes", "(", ")", "->", "$", "name", ";", "if", "(", "!", "empty", "(", "$", "v", ")", ")", "return", "(", "string", ")", "$", "v", ";", "}" ]
Retrieves and attribute by name @param string $name The name of the attribute to get @return mixed Returns nothing if not found, or a string for the value of the found attribute
[ "Retrieves", "and", "attribute", "by", "name" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/xml/SimpleXMLExtended.php#L35-L40
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/xml/SimpleXMLExtended.php
SimpleXMLExtended.xpathNSOne
public function xpathNSOne($path, $namespaces) { $result = $this->xpathNS($path, $namespaces); if(is_array($result)) return current($result); return $result; }
php
public function xpathNSOne($path, $namespaces) { $result = $this->xpathNS($path, $namespaces); if(is_array($result)) return current($result); return $result; }
[ "public", "function", "xpathNSOne", "(", "$", "path", ",", "$", "namespaces", ")", "{", "$", "result", "=", "$", "this", "->", "xpathNS", "(", "$", "path", ",", "$", "namespaces", ")", ";", "if", "(", "is_array", "(", "$", "result", ")", ")", "return", "current", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Queries for a single result of an xpath query respecting the namespaces given @param string $path The xpath query @param array $namespaces The namespaces [prefix => ns] @see SimpleXML::registerXPathNamespace() @return mixed The SimpleXMLElement that matches the xpath query or FALSE
[ "Queries", "for", "a", "single", "result", "of", "an", "xpath", "query", "respecting", "the", "namespaces", "given" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/xml/SimpleXMLExtended.php#L71-L79
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/xml/SimpleXMLExtended.php
SimpleXMLExtended.xpathOne
public function xpathOne($path) { $result = $this->xpath($path); if(is_array($result)) return current($result); return $result; }
php
public function xpathOne($path) { $result = $this->xpath($path); if(is_array($result)) return current($result); return $result; }
[ "public", "function", "xpathOne", "(", "$", "path", ")", "{", "$", "result", "=", "$", "this", "->", "xpath", "(", "$", "path", ")", ";", "if", "(", "is_array", "(", "$", "result", ")", ")", "return", "current", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Query an xpath and return the first result @param string $path The xpath query @return SimpleXMLElement The matching result or FALSE
[ "Query", "an", "xpath", "and", "return", "the", "first", "result" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/xml/SimpleXMLExtended.php#L88-L96
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/xml/SimpleXMLExtended.php
SimpleXMLExtended.addChild
public function addChild($name, $value=null, $namespace=null) { $esc_val = utf8_encode(htmlentities($value, ENT_QUOTES, 'UTF-8', false)); if ($value == $esc_val) return parent::addChild($name, $esc_val, $namespace); else { $xml_field = parent::addChild($name, '', $namespace); $xml_field->addCData($esc_val); $xml_field->addAttribute('isCDATA', true); return $xml_field; } }
php
public function addChild($name, $value=null, $namespace=null) { $esc_val = utf8_encode(htmlentities($value, ENT_QUOTES, 'UTF-8', false)); if ($value == $esc_val) return parent::addChild($name, $esc_val, $namespace); else { $xml_field = parent::addChild($name, '', $namespace); $xml_field->addCData($esc_val); $xml_field->addAttribute('isCDATA', true); return $xml_field; } }
[ "public", "function", "addChild", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "namespace", "=", "null", ")", "{", "$", "esc_val", "=", "utf8_encode", "(", "htmlentities", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ",", "false", ")", ")", ";", "if", "(", "$", "value", "==", "$", "esc_val", ")", "return", "parent", "::", "addChild", "(", "$", "name", ",", "$", "esc_val", ",", "$", "namespace", ")", ";", "else", "{", "$", "xml_field", "=", "parent", "::", "addChild", "(", "$", "name", ",", "''", ",", "$", "namespace", ")", ";", "$", "xml_field", "->", "addCData", "(", "$", "esc_val", ")", ";", "$", "xml_field", "->", "addAttribute", "(", "'isCDATA'", ",", "true", ")", ";", "return", "$", "xml_field", ";", "}", "}" ]
Adds a child to the current element, but with automatic CDATA support. @param string $name The name of the child element to add @param string $value The value of the child element @param string $namespace If specified, use this namespace @return SimpleXMLElement a SimpleXMLElement object representing the child added to the XML node.
[ "Adds", "a", "child", "to", "the", "current", "element", "but", "with", "automatic", "CDATA", "support", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/xml/SimpleXMLExtended.php#L121-L133
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/xml/SimpleXMLExtended.php
SimpleXMLExtended.replace
public function replace(SimpleXMLExtended $child) { $node1 = dom_import_simplexml($this); $dom_sxe = dom_import_simplexml($child); $node2 = $node1->ownerDocument->importNode($dom_sxe, true); $node1->parentNode->replaceChild($node2, $node1); return $this; }
php
public function replace(SimpleXMLExtended $child) { $node1 = dom_import_simplexml($this); $dom_sxe = dom_import_simplexml($child); $node2 = $node1->ownerDocument->importNode($dom_sxe, true); $node1->parentNode->replaceChild($node2, $node1); return $this; }
[ "public", "function", "replace", "(", "SimpleXMLExtended", "$", "child", ")", "{", "$", "node1", "=", "dom_import_simplexml", "(", "$", "this", ")", ";", "$", "dom_sxe", "=", "dom_import_simplexml", "(", "$", "child", ")", ";", "$", "node2", "=", "$", "node1", "->", "ownerDocument", "->", "importNode", "(", "$", "dom_sxe", ",", "true", ")", ";", "$", "node1", "->", "parentNode", "->", "replaceChild", "(", "$", "node2", ",", "$", "node1", ")", ";", "return", "$", "this", ";", "}" ]
Replaces the current element with the element specified @param SimpleXMLExtended $child The element to replace me @return this
[ "Replaces", "the", "current", "element", "with", "the", "element", "specified" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/xml/SimpleXMLExtended.php#L173-L181
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/xml/SimpleXMLExtended.php
SimpleXMLExtended.asPrettyXML
public function asPrettyXML($level = 4) { // removed duplicate XML start of the document declaration $xml = preg_replace('/\<\?xml([^\>\/]*)\>/', '' , $this->asXML()); $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml); $formatted = $dom->saveXml(); return $formatted; }
php
public function asPrettyXML($level = 4) { // removed duplicate XML start of the document declaration $xml = preg_replace('/\<\?xml([^\>\/]*)\>/', '' , $this->asXML()); $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml); $formatted = $dom->saveXml(); return $formatted; }
[ "public", "function", "asPrettyXML", "(", "$", "level", "=", "4", ")", "{", "// removed duplicate XML start of the document declaration", "$", "xml", "=", "preg_replace", "(", "'/\\<\\?xml([^\\>\\/]*)\\>/'", ",", "''", ",", "$", "this", "->", "asXML", "(", ")", ")", ";", "$", "dom", "=", "new", "DOMDocument", "(", ")", ";", "$", "dom", "->", "preserveWhiteSpace", "=", "false", ";", "$", "dom", "->", "formatOutput", "=", "true", ";", "$", "dom", "->", "loadXML", "(", "$", "xml", ")", ";", "$", "formatted", "=", "$", "dom", "->", "saveXml", "(", ")", ";", "return", "$", "formatted", ";", "}" ]
Returns a properly indented form of the current XML tree @param string $level The number of spaces to use as indentation. @return string Beautifully formatted XML code that will make your mom smile. Use your manners! @deprecated $level is deprecated in 3.2.9, to be removed in 3.3.
[ "Returns", "a", "properly", "indented", "form", "of", "the", "current", "XML", "tree" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/xml/SimpleXMLExtended.php#L206-L218
train
LartTyler/PHP-Enum
src/DaybreakStudios/Enum/Enum.php
Enum.valueOf
public static function valueOf($str) { $key = get_called_class(); if (!array_key_exists($key, self::$types)) return null; $str = str_replace(array(' ', '-'), '_', trim($str)); if (array_key_exists($str, self::$types[$key])) return self::$types[$key][$str]; return null; }
php
public static function valueOf($str) { $key = get_called_class(); if (!array_key_exists($key, self::$types)) return null; $str = str_replace(array(' ', '-'), '_', trim($str)); if (array_key_exists($str, self::$types[$key])) return self::$types[$key][$str]; return null; }
[ "public", "static", "function", "valueOf", "(", "$", "str", ")", "{", "$", "key", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "self", "::", "$", "types", ")", ")", "return", "null", ";", "$", "str", "=", "str_replace", "(", "array", "(", "' '", ",", "'-'", ")", ",", "'_'", ",", "trim", "(", "$", "str", ")", ")", ";", "if", "(", "array_key_exists", "(", "$", "str", ",", "self", "::", "$", "types", "[", "$", "key", "]", ")", ")", "return", "self", "::", "$", "types", "[", "$", "key", "]", "[", "$", "str", "]", ";", "return", "null", ";", "}" ]
Attempts to match a string name to an enum element. Strings passed to this method will be converted to a format allowable in an enum name. That is to say, they will have any spaces or dashes converted to underscores, and all whitespace on either side of the string will be trimmed. @param string $str the string to match to an enum element name @return the matched enum element, or null if one could not be found
[ "Attempts", "to", "match", "a", "string", "name", "to", "an", "enum", "element", "." ]
58fa321b74969931631f875a208792b3b4ffa776
https://github.com/LartTyler/PHP-Enum/blob/58fa321b74969931631f875a208792b3b4ffa776/src/DaybreakStudios/Enum/Enum.php#L132-L144
train
faizalpribadi/Event
ObjectEvent.php
ObjectEvent.getParameter
public function getParameter($key) { if ($this->hasParameter($key)) { return $this->parameters[$key]; } throw new \InvalidArgumentException( sprintf('Wrong parameter key "%s" , invalid returned the key', $key) ); }
php
public function getParameter($key) { if ($this->hasParameter($key)) { return $this->parameters[$key]; } throw new \InvalidArgumentException( sprintf('Wrong parameter key "%s" , invalid returned the key', $key) ); }
[ "public", "function", "getParameter", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "hasParameter", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "parameters", "[", "$", "key", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong parameter key \"%s\" , invalid returned the key'", ",", "$", "key", ")", ")", ";", "}" ]
Get the parameter of object event @param string|array $key @return string|array mixed @throws \InvalidArgumentException
[ "Get", "the", "parameter", "of", "object", "event" ]
f1bbd2d018b31b926ede66fd6b0787fbf38e6e99
https://github.com/faizalpribadi/Event/blob/f1bbd2d018b31b926ede66fd6b0787fbf38e6e99/ObjectEvent.php#L72-L81
train
bseddon/XPath20
Tokenizer.php
StringReader.read
public function read() { $this->position++; if ( $this->position >= count( $this->buffer ) ) return false; return $this->buffer[ $this->position ]; }
php
public function read() { $this->position++; if ( $this->position >= count( $this->buffer ) ) return false; return $this->buffer[ $this->position ]; }
[ "public", "function", "read", "(", ")", "{", "$", "this", "->", "position", "++", ";", "if", "(", "$", "this", "->", "position", ">=", "count", "(", "$", "this", "->", "buffer", ")", ")", "return", "false", ";", "return", "$", "this", "->", "buffer", "[", "$", "this", "->", "position", "]", ";", "}" ]
Read the buffer and the current position @return boolean|mixed
[ "Read", "the", "buffer", "and", "the", "current", "position" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Tokenizer.php#L1930-L1936
train
bseddon/XPath20
Tokenizer.php
StringReader.peek
public function peek() { $peekPosition = $this->position + 1; // BMS 2017-09-05 This should return -1. False is equivalent to zero which is a valid buffer offset value. if ( $peekPosition >= count( $this->buffer ) ) return -1; // false; return $this->buffer[ $peekPosition ]; }
php
public function peek() { $peekPosition = $this->position + 1; // BMS 2017-09-05 This should return -1. False is equivalent to zero which is a valid buffer offset value. if ( $peekPosition >= count( $this->buffer ) ) return -1; // false; return $this->buffer[ $peekPosition ]; }
[ "public", "function", "peek", "(", ")", "{", "$", "peekPosition", "=", "$", "this", "->", "position", "+", "1", ";", "// BMS 2017-09-05 This should return -1. False is equivalent to zero which is a valid buffer offset value.\r", "if", "(", "$", "peekPosition", ">=", "count", "(", "$", "this", "->", "buffer", ")", ")", "return", "-", "1", ";", "// false;\r", "return", "$", "this", "->", "buffer", "[", "$", "peekPosition", "]", ";", "}" ]
Look one char ahead in the buffer @return number|mixed
[ "Look", "one", "char", "ahead", "in", "the", "buffer" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Tokenizer.php#L1942-L1949
train
jmfeurprier/perf-database
lib/perf/Db/QueryFilter.php
QueryFilter.mergeAnd
public function mergeAnd(self $filter) { $clause = "({$this->clause}) AND ({$filter->clause})"; $parameters = array_merge($this->parameters, $filter->parameters); return new self($clause, $parameters); }
php
public function mergeAnd(self $filter) { $clause = "({$this->clause}) AND ({$filter->clause})"; $parameters = array_merge($this->parameters, $filter->parameters); return new self($clause, $parameters); }
[ "public", "function", "mergeAnd", "(", "self", "$", "filter", ")", "{", "$", "clause", "=", "\"({$this->clause}) AND ({$filter->clause})\"", ";", "$", "parameters", "=", "array_merge", "(", "$", "this", "->", "parameters", ",", "$", "filter", "->", "parameters", ")", ";", "return", "new", "self", "(", "$", "clause", ",", "$", "parameters", ")", ";", "}" ]
Combines two filters together with a "AND" operator. Current and provided instances will not be altered; the returned new instance will hold the result of the computation. @param QueryFilter $filter The filter to be added to the current instance. @return QueryFilter
[ "Combines", "two", "filters", "together", "with", "a", "AND", "operator", ".", "Current", "and", "provided", "instances", "will", "not", "be", "altered", ";", "the", "returned", "new", "instance", "will", "hold", "the", "result", "of", "the", "computation", "." ]
9b39dc76be9f8a33d02aadc168fdb74d786f0ff2
https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/QueryFilter.php#L80-L86
train
jmfeurprier/perf-database
lib/perf/Db/QueryFilter.php
QueryFilter.mergeOr
public function mergeOr(self $filter) { $clause = "({$this->clause}) OR ({$filter->clause})"; $parameters = array_merge($this->parameters, $filter->parameters); return new self($clause, $parameters); }
php
public function mergeOr(self $filter) { $clause = "({$this->clause}) OR ({$filter->clause})"; $parameters = array_merge($this->parameters, $filter->parameters); return new self($clause, $parameters); }
[ "public", "function", "mergeOr", "(", "self", "$", "filter", ")", "{", "$", "clause", "=", "\"({$this->clause}) OR ({$filter->clause})\"", ";", "$", "parameters", "=", "array_merge", "(", "$", "this", "->", "parameters", ",", "$", "filter", "->", "parameters", ")", ";", "return", "new", "self", "(", "$", "clause", ",", "$", "parameters", ")", ";", "}" ]
Combines two filters together with a "OR" operator. Current and provided instances will not be altered; the returned new instance will hold the result of the computation. @param QueryFilter $filter The filter to be added to the current instance. @return QueryFilter
[ "Combines", "two", "filters", "together", "with", "a", "OR", "operator", ".", "Current", "and", "provided", "instances", "will", "not", "be", "altered", ";", "the", "returned", "new", "instance", "will", "hold", "the", "result", "of", "the", "computation", "." ]
9b39dc76be9f8a33d02aadc168fdb74d786f0ff2
https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/QueryFilter.php#L95-L101
train
squareproton/Bond
src/Bond/Di/ProxyFactoryNative.php
ProxyFactoryNative.resolve
private function resolve(Definition $definition) { if(!$this->container->isFrozen()) { throw new \LogicException("cannot use create method on factory without freezing/compiling container"); } $subContainer = new ContainerBuilder(); $subContainer->merge($this->container); $subContainer->setDefinition("__tmp__", $definition); $subContainer->compile(); $obj = $subContainer->get("__tmp__"); return $obj; }
php
private function resolve(Definition $definition) { if(!$this->container->isFrozen()) { throw new \LogicException("cannot use create method on factory without freezing/compiling container"); } $subContainer = new ContainerBuilder(); $subContainer->merge($this->container); $subContainer->setDefinition("__tmp__", $definition); $subContainer->compile(); $obj = $subContainer->get("__tmp__"); return $obj; }
[ "private", "function", "resolve", "(", "Definition", "$", "definition", ")", "{", "if", "(", "!", "$", "this", "->", "container", "->", "isFrozen", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"cannot use create method on factory without freezing/compiling container\"", ")", ";", "}", "$", "subContainer", "=", "new", "ContainerBuilder", "(", ")", ";", "$", "subContainer", "->", "merge", "(", "$", "this", "->", "container", ")", ";", "$", "subContainer", "->", "setDefinition", "(", "\"__tmp__\"", ",", "$", "definition", ")", ";", "$", "subContainer", "->", "compile", "(", ")", ";", "$", "obj", "=", "$", "subContainer", "->", "get", "(", "\"__tmp__\"", ")", ";", "return", "$", "obj", ";", "}" ]
todo heavy optimization likely to be needed for this method
[ "todo", "heavy", "optimization", "likely", "to", "be", "needed", "for", "this", "method" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Di/ProxyFactoryNative.php#L68-L79
train
dms-org/common.structure
src/FileSystem/PathHelper.php
PathHelper.normalize
public static function normalize(string $path) : string { if (strpos($path, 'data://') === 0) { return $path; } $path = self::stringReplaceIgnoringStreamWrapper(['\\', '/'], DIRECTORY_SEPARATOR, $path); $startOfPath = strpos($path, '://') === false ? 0 : strpos($path, '://') + strlen('://'); while (strpos($path, DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, $startOfPath) !== false) { $path = self::stringReplaceIgnoringStreamWrapper(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path); } return $path; }
php
public static function normalize(string $path) : string { if (strpos($path, 'data://') === 0) { return $path; } $path = self::stringReplaceIgnoringStreamWrapper(['\\', '/'], DIRECTORY_SEPARATOR, $path); $startOfPath = strpos($path, '://') === false ? 0 : strpos($path, '://') + strlen('://'); while (strpos($path, DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, $startOfPath) !== false) { $path = self::stringReplaceIgnoringStreamWrapper(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path); } return $path; }
[ "public", "static", "function", "normalize", "(", "string", "$", "path", ")", ":", "string", "{", "if", "(", "strpos", "(", "$", "path", ",", "'data://'", ")", "===", "0", ")", "{", "return", "$", "path", ";", "}", "$", "path", "=", "self", "::", "stringReplaceIgnoringStreamWrapper", "(", "[", "'\\\\'", ",", "'/'", "]", ",", "DIRECTORY_SEPARATOR", ",", "$", "path", ")", ";", "$", "startOfPath", "=", "strpos", "(", "$", "path", ",", "'://'", ")", "===", "false", "?", "0", ":", "strpos", "(", "$", "path", ",", "'://'", ")", "+", "strlen", "(", "'://'", ")", ";", "while", "(", "strpos", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ".", "DIRECTORY_SEPARATOR", ",", "$", "startOfPath", ")", "!==", "false", ")", "{", "$", "path", "=", "self", "::", "stringReplaceIgnoringStreamWrapper", "(", "DIRECTORY_SEPARATOR", ".", "DIRECTORY_SEPARATOR", ",", "DIRECTORY_SEPARATOR", ",", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Normalizes the supplied path @param string $path @return string
[ "Normalizes", "the", "supplied", "path" ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/FileSystem/PathHelper.php#L19-L35
train
dms-org/common.structure
src/FileSystem/PathHelper.php
PathHelper.combine
public static function combine(string ... $paths) : string { $paths = array_map([__CLASS__, 'normalize'], $paths); $paths = array_filter($paths, function ($path) { return trim($path, DIRECTORY_SEPARATOR) !== '.'; }); $combinedPath = implode(DIRECTORY_SEPARATOR, $paths); return self::stringReplaceIgnoringStreamWrapper( DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $combinedPath ); }
php
public static function combine(string ... $paths) : string { $paths = array_map([__CLASS__, 'normalize'], $paths); $paths = array_filter($paths, function ($path) { return trim($path, DIRECTORY_SEPARATOR) !== '.'; }); $combinedPath = implode(DIRECTORY_SEPARATOR, $paths); return self::stringReplaceIgnoringStreamWrapper( DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $combinedPath ); }
[ "public", "static", "function", "combine", "(", "string", "...", "$", "paths", ")", ":", "string", "{", "$", "paths", "=", "array_map", "(", "[", "__CLASS__", ",", "'normalize'", "]", ",", "$", "paths", ")", ";", "$", "paths", "=", "array_filter", "(", "$", "paths", ",", "function", "(", "$", "path", ")", "{", "return", "trim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", "!==", "'.'", ";", "}", ")", ";", "$", "combinedPath", "=", "implode", "(", "DIRECTORY_SEPARATOR", ",", "$", "paths", ")", ";", "return", "self", "::", "stringReplaceIgnoringStreamWrapper", "(", "DIRECTORY_SEPARATOR", ".", "DIRECTORY_SEPARATOR", ",", "DIRECTORY_SEPARATOR", ",", "$", "combinedPath", ")", ";", "}" ]
Combines the supplied paths @param string[] $paths @return string
[ "Combines", "the", "supplied", "paths" ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/FileSystem/PathHelper.php#L44-L59
train
modulusphp/security
Auth.php
Auth.routes
public static function routes() { Route::group(['namespace' => 'Auth'], function () { Route::group(['middleware' => ['guest']], function () { Route::get('login', 'LoginController@showLoginPage')->name('showLogin'); Route::post('login', 'LoginController@login')->name('login'); Route::get('login/email', 'LoginController@showMagicLinkPage')->name('showMagicLink'); Route::post('login/email', 'LoginController@loginWithEmail')->name('loginWithEmail'); Route::get('login/callback/email/', 'LoginController@loginEmailCallback')->name('loginCallback'); Route::get('register', 'RegisterController@showRegistrationPage')->name('showRegistration'); Route::post('register', 'RegisterController@register')->name('register'); Route::get('password/forgot', 'ForgotPasswordController@showForgotPasswordPage')->name('showForgotPassword'); Route::post('password/forgot', 'ForgotPasswordController@forgot')->name('forgot'); Route::get('password/reset', 'ForgotPasswordController@showResetPasswordPage')->name('showResetPassword'); Route::post('password/reset', 'ForgotPasswordController@resetPassword')->name('resetPassword'); }); Route::get('logout', 'LoginController@logout')->name('logout')->middleware('private', 'auth'); Route::get('account/verify', 'RegisterController@verifyEmail')->name('verify'); }); }
php
public static function routes() { Route::group(['namespace' => 'Auth'], function () { Route::group(['middleware' => ['guest']], function () { Route::get('login', 'LoginController@showLoginPage')->name('showLogin'); Route::post('login', 'LoginController@login')->name('login'); Route::get('login/email', 'LoginController@showMagicLinkPage')->name('showMagicLink'); Route::post('login/email', 'LoginController@loginWithEmail')->name('loginWithEmail'); Route::get('login/callback/email/', 'LoginController@loginEmailCallback')->name('loginCallback'); Route::get('register', 'RegisterController@showRegistrationPage')->name('showRegistration'); Route::post('register', 'RegisterController@register')->name('register'); Route::get('password/forgot', 'ForgotPasswordController@showForgotPasswordPage')->name('showForgotPassword'); Route::post('password/forgot', 'ForgotPasswordController@forgot')->name('forgot'); Route::get('password/reset', 'ForgotPasswordController@showResetPasswordPage')->name('showResetPassword'); Route::post('password/reset', 'ForgotPasswordController@resetPassword')->name('resetPassword'); }); Route::get('logout', 'LoginController@logout')->name('logout')->middleware('private', 'auth'); Route::get('account/verify', 'RegisterController@verifyEmail')->name('verify'); }); }
[ "public", "static", "function", "routes", "(", ")", "{", "Route", "::", "group", "(", "[", "'namespace'", "=>", "'Auth'", "]", ",", "function", "(", ")", "{", "Route", "::", "group", "(", "[", "'middleware'", "=>", "[", "'guest'", "]", "]", ",", "function", "(", ")", "{", "Route", "::", "get", "(", "'login'", ",", "'LoginController@showLoginPage'", ")", "->", "name", "(", "'showLogin'", ")", ";", "Route", "::", "post", "(", "'login'", ",", "'LoginController@login'", ")", "->", "name", "(", "'login'", ")", ";", "Route", "::", "get", "(", "'login/email'", ",", "'LoginController@showMagicLinkPage'", ")", "->", "name", "(", "'showMagicLink'", ")", ";", "Route", "::", "post", "(", "'login/email'", ",", "'LoginController@loginWithEmail'", ")", "->", "name", "(", "'loginWithEmail'", ")", ";", "Route", "::", "get", "(", "'login/callback/email/'", ",", "'LoginController@loginEmailCallback'", ")", "->", "name", "(", "'loginCallback'", ")", ";", "Route", "::", "get", "(", "'register'", ",", "'RegisterController@showRegistrationPage'", ")", "->", "name", "(", "'showRegistration'", ")", ";", "Route", "::", "post", "(", "'register'", ",", "'RegisterController@register'", ")", "->", "name", "(", "'register'", ")", ";", "Route", "::", "get", "(", "'password/forgot'", ",", "'ForgotPasswordController@showForgotPasswordPage'", ")", "->", "name", "(", "'showForgotPassword'", ")", ";", "Route", "::", "post", "(", "'password/forgot'", ",", "'ForgotPasswordController@forgot'", ")", "->", "name", "(", "'forgot'", ")", ";", "Route", "::", "get", "(", "'password/reset'", ",", "'ForgotPasswordController@showResetPasswordPage'", ")", "->", "name", "(", "'showResetPassword'", ")", ";", "Route", "::", "post", "(", "'password/reset'", ",", "'ForgotPasswordController@resetPassword'", ")", "->", "name", "(", "'resetPassword'", ")", ";", "}", ")", ";", "Route", "::", "get", "(", "'logout'", ",", "'LoginController@logout'", ")", "->", "name", "(", "'logout'", ")", "->", "middleware", "(", "'private'", ",", "'auth'", ")", ";", "Route", "::", "get", "(", "'account/verify'", ",", "'RegisterController@verifyEmail'", ")", "->", "name", "(", "'verify'", ")", ";", "}", ")", ";", "}" ]
Register auth routes @return void
[ "Register", "auth", "routes" ]
7a0b7f7a23f682588a3582b810d61266f7c14567
https://github.com/modulusphp/security/blob/7a0b7f7a23f682588a3582b810d61266f7c14567/Auth.php#L32-L60
train
anime-db/catalog-bundle
src/Plugin/Fill/Filler/Filler.php
Filler.fillFromSearchResult
public function fillFromSearchResult(ItemSearch $item) { $query = parse_url($item->getLink(), PHP_URL_QUERY); parse_str($query, $query); if (empty($query[$this->getForm()->getName()])) { return; } return $this->fill($query[$this->getForm()->getName()]); }
php
public function fillFromSearchResult(ItemSearch $item) { $query = parse_url($item->getLink(), PHP_URL_QUERY); parse_str($query, $query); if (empty($query[$this->getForm()->getName()])) { return; } return $this->fill($query[$this->getForm()->getName()]); }
[ "public", "function", "fillFromSearchResult", "(", "ItemSearch", "$", "item", ")", "{", "$", "query", "=", "parse_url", "(", "$", "item", "->", "getLink", "(", ")", ",", "PHP_URL_QUERY", ")", ";", "parse_str", "(", "$", "query", ",", "$", "query", ")", ";", "if", "(", "empty", "(", "$", "query", "[", "$", "this", "->", "getForm", "(", ")", "->", "getName", "(", ")", "]", ")", ")", "{", "return", ";", "}", "return", "$", "this", "->", "fill", "(", "$", "query", "[", "$", "this", "->", "getForm", "(", ")", "->", "getName", "(", ")", "]", ")", ";", "}" ]
Fill from search result. @param ItemSearch $item @return Item|null
[ "Fill", "from", "search", "result", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Plugin/Fill/Filler/Filler.php#L89-L98
train
stubbles/stubbles-date
src/main/php/span/Month.php
Month.asString
public function asString(): string { return (string) $this->year . '-' . ((10 > $this->month && strlen((string) $this->month) === 1) ? ('0' . $this->month) : ($this->month)); }
php
public function asString(): string { return (string) $this->year . '-' . ((10 > $this->month && strlen((string) $this->month) === 1) ? ('0' . $this->month) : ($this->month)); }
[ "public", "function", "asString", "(", ")", ":", "string", "{", "return", "(", "string", ")", "$", "this", "->", "year", ".", "'-'", ".", "(", "(", "10", ">", "$", "this", "->", "month", "&&", "strlen", "(", "(", "string", ")", "$", "this", "->", "month", ")", "===", "1", ")", "?", "(", "'0'", ".", "$", "this", "->", "month", ")", ":", "(", "$", "this", "->", "month", ")", ")", ";", "}" ]
returns a string representation of the date object @return string
[ "returns", "a", "string", "representation", "of", "the", "date", "object" ]
98553392bec03affc53a6e3eb7f88408c2720d1c
https://github.com/stubbles/stubbles-date/blob/98553392bec03affc53a6e3eb7f88408c2720d1c/src/main/php/span/Month.php#L199-L202
train
JumpGateio/Core
src/JumpGate/Core/Http/Controllers/BaseController.php
BaseController.setViewData
protected function setViewData($key, $value = null) { if (is_array($key)) { foreach ($key as $name => $data) { view()->share($name, $data); } } else { view()->share($key, $value); } }
php
protected function setViewData($key, $value = null) { if (is_array($key)) { foreach ($key as $name => $data) { view()->share($name, $data); } } else { view()->share($key, $value); } }
[ "protected", "function", "setViewData", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "name", "=>", "$", "data", ")", "{", "view", "(", ")", "->", "share", "(", "$", "name", ",", "$", "data", ")", ";", "}", "}", "else", "{", "view", "(", ")", "->", "share", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Pass data to the view. @param mixed $key @param mixed $value
[ "Pass", "data", "to", "the", "view", "." ]
485b5cf03b3072267bffbee428b81e48d407d6b6
https://github.com/JumpGateio/Core/blob/485b5cf03b3072267bffbee428b81e48d407d6b6/src/JumpGate/Core/Http/Controllers/BaseController.php#L32-L41
train
Danack/Weaver
src/Weaver/SingleClassWeaveGenerator.php
SingleClassWeaveGenerator.addPropertiesAndConstantsFromReflection
function addPropertiesAndConstantsFromReflection(ClassReflection $classReflection ) { $constants = $classReflection->getConstants(); foreach ($constants as $name => $value) { $this->generator->addProperty($name, $value, PropertyGenerator::FLAG_CONSTANT); } $properties = $classReflection->getProperties(); foreach ($properties as $property) { $newProperty = PropertyGenerator::fromReflection($property); $newProperty->setVisibility(\Danack\Code\Generator\AbstractMemberGenerator::FLAG_PRIVATE); $this->generator->addPropertyFromGenerator($newProperty); } }
php
function addPropertiesAndConstantsFromReflection(ClassReflection $classReflection ) { $constants = $classReflection->getConstants(); foreach ($constants as $name => $value) { $this->generator->addProperty($name, $value, PropertyGenerator::FLAG_CONSTANT); } $properties = $classReflection->getProperties(); foreach ($properties as $property) { $newProperty = PropertyGenerator::fromReflection($property); $newProperty->setVisibility(\Danack\Code\Generator\AbstractMemberGenerator::FLAG_PRIVATE); $this->generator->addPropertyFromGenerator($newProperty); } }
[ "function", "addPropertiesAndConstantsFromReflection", "(", "ClassReflection", "$", "classReflection", ")", "{", "$", "constants", "=", "$", "classReflection", "->", "getConstants", "(", ")", ";", "foreach", "(", "$", "constants", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "generator", "->", "addProperty", "(", "$", "name", ",", "$", "value", ",", "PropertyGenerator", "::", "FLAG_CONSTANT", ")", ";", "}", "$", "properties", "=", "$", "classReflection", "->", "getProperties", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "newProperty", "=", "PropertyGenerator", "::", "fromReflection", "(", "$", "property", ")", ";", "$", "newProperty", "->", "setVisibility", "(", "\\", "Danack", "\\", "Code", "\\", "Generator", "\\", "AbstractMemberGenerator", "::", "FLAG_PRIVATE", ")", ";", "$", "this", "->", "generator", "->", "addPropertyFromGenerator", "(", "$", "newProperty", ")", ";", "}", "}" ]
addPropertiesAndConstantsFromReflection - does what it's name says. @param ClassReflection $classReflection @internal param $originalSourceClass
[ "addPropertiesAndConstantsFromReflection", "-", "does", "what", "it", "s", "name", "says", "." ]
414894cd397daff22d2c71e4988784a1f71b702e
https://github.com/Danack/Weaver/blob/414894cd397daff22d2c71e4988784a1f71b702e/src/Weaver/SingleClassWeaveGenerator.php#L61-L73
train
GoIntegro/json
JsonCoder.php
JsonCoder.matchSchema
public function matchSchema($json, $schema) { $validator = new Validator(); if (is_string($json)) { $json = $this->decode($json, TRUE); } elseif (is_array($json)) { $json = (object) $json; } if (is_string($schema)) { $schema = $this->decode($schema, TRUE); } elseif (is_array($schema)) { $schema = (object) $schema; } $validator->check($json, $schema); $this->lastSchemaErrors = $validator->getErrors(); return $validator->isValid(); }
php
public function matchSchema($json, $schema) { $validator = new Validator(); if (is_string($json)) { $json = $this->decode($json, TRUE); } elseif (is_array($json)) { $json = (object) $json; } if (is_string($schema)) { $schema = $this->decode($schema, TRUE); } elseif (is_array($schema)) { $schema = (object) $schema; } $validator->check($json, $schema); $this->lastSchemaErrors = $validator->getErrors(); return $validator->isValid(); }
[ "public", "function", "matchSchema", "(", "$", "json", ",", "$", "schema", ")", "{", "$", "validator", "=", "new", "Validator", "(", ")", ";", "if", "(", "is_string", "(", "$", "json", ")", ")", "{", "$", "json", "=", "$", "this", "->", "decode", "(", "$", "json", ",", "TRUE", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "json", ")", ")", "{", "$", "json", "=", "(", "object", ")", "$", "json", ";", "}", "if", "(", "is_string", "(", "$", "schema", ")", ")", "{", "$", "schema", "=", "$", "this", "->", "decode", "(", "$", "schema", ",", "TRUE", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "schema", ")", ")", "{", "$", "schema", "=", "(", "object", ")", "$", "schema", ";", "}", "$", "validator", "->", "check", "(", "$", "json", ",", "$", "schema", ")", ";", "$", "this", "->", "lastSchemaErrors", "=", "$", "validator", "->", "getErrors", "(", ")", ";", "return", "$", "validator", "->", "isValid", "(", ")", ";", "}" ]
Matches a JSON string or structure to a schema. It would be lovely to be able to return an object containing both the result and the errors wich would itself be castable to boolean, but alas, this is not yet possible on PHP. @param string $json @param string $schema @return boolean @see http://json-schema.org/
[ "Matches", "a", "JSON", "string", "or", "structure", "to", "a", "schema", "." ]
d1b1401176d5a1e9883c30ade9c60bafb6afcb14
https://github.com/GoIntegro/json/blob/d1b1401176d5a1e9883c30ade9c60bafb6afcb14/JsonCoder.php#L107-L127
train
GoIntegro/json
JsonCoder.php
JsonCoder.getSchemaErrorMessage
public function getSchemaErrorMessage() { $message = NULL; foreach ($this->lastSchemaErrors as $error) { $message .= sprintf( "[%s] %s\n", $error['property'], $error['message'] ); } if (!empty($message)) { $message = self::FAIL_JSON_SCHEMA_MESSAGE . $message; } return $message; }
php
public function getSchemaErrorMessage() { $message = NULL; foreach ($this->lastSchemaErrors as $error) { $message .= sprintf( "[%s] %s\n", $error['property'], $error['message'] ); } if (!empty($message)) { $message = self::FAIL_JSON_SCHEMA_MESSAGE . $message; } return $message; }
[ "public", "function", "getSchemaErrorMessage", "(", ")", "{", "$", "message", "=", "NULL", ";", "foreach", "(", "$", "this", "->", "lastSchemaErrors", "as", "$", "error", ")", "{", "$", "message", ".=", "sprintf", "(", "\"[%s] %s\\n\"", ",", "$", "error", "[", "'property'", "]", ",", "$", "error", "[", "'message'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "$", "message", "=", "self", "::", "FAIL_JSON_SCHEMA_MESSAGE", ".", "$", "message", ";", "}", "return", "$", "message", ";", "}" ]
Returns the latest schema matching errors as a text message. @return string @see http://php.net/manual/en/function.json-last-error-msg.php
[ "Returns", "the", "latest", "schema", "matching", "errors", "as", "a", "text", "message", "." ]
d1b1401176d5a1e9883c30ade9c60bafb6afcb14
https://github.com/GoIntegro/json/blob/d1b1401176d5a1e9883c30ade9c60bafb6afcb14/JsonCoder.php#L144-L159
train
cubicmushroom/valueobjects
src/Structure/Dictionary.php
Dictionary.fromNative
public static function fromNative() { $array = \func_get_arg(0); $keyValuePairs = array(); foreach ($array as $arrayKey => $arrayValue) { $key = new StringLiteral(\strval($arrayKey)); if ($arrayValue instanceof \Traversable || \is_array($arrayValue)) { $value = Collection::fromNative($arrayValue); } else { $value = new StringLiteral(\strval($arrayValue)); } $keyValuePairs[] = new KeyValuePair($key, $value); } $fixedArray = \SplFixedArray::fromArray($keyValuePairs); return new self($fixedArray); }
php
public static function fromNative() { $array = \func_get_arg(0); $keyValuePairs = array(); foreach ($array as $arrayKey => $arrayValue) { $key = new StringLiteral(\strval($arrayKey)); if ($arrayValue instanceof \Traversable || \is_array($arrayValue)) { $value = Collection::fromNative($arrayValue); } else { $value = new StringLiteral(\strval($arrayValue)); } $keyValuePairs[] = new KeyValuePair($key, $value); } $fixedArray = \SplFixedArray::fromArray($keyValuePairs); return new self($fixedArray); }
[ "public", "static", "function", "fromNative", "(", ")", "{", "$", "array", "=", "\\", "func_get_arg", "(", "0", ")", ";", "$", "keyValuePairs", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "arrayKey", "=>", "$", "arrayValue", ")", "{", "$", "key", "=", "new", "StringLiteral", "(", "\\", "strval", "(", "$", "arrayKey", ")", ")", ";", "if", "(", "$", "arrayValue", "instanceof", "\\", "Traversable", "||", "\\", "is_array", "(", "$", "arrayValue", ")", ")", "{", "$", "value", "=", "Collection", "::", "fromNative", "(", "$", "arrayValue", ")", ";", "}", "else", "{", "$", "value", "=", "new", "StringLiteral", "(", "\\", "strval", "(", "$", "arrayValue", ")", ")", ";", "}", "$", "keyValuePairs", "[", "]", "=", "new", "KeyValuePair", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "fixedArray", "=", "\\", "SplFixedArray", "::", "fromArray", "(", "$", "keyValuePairs", ")", ";", "return", "new", "self", "(", "$", "fixedArray", ")", ";", "}" ]
Returns a new Dictionary object @param array $array @return self
[ "Returns", "a", "new", "Dictionary", "object" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Structure/Dictionary.php#L16-L36
train
cubicmushroom/valueobjects
src/Structure/Dictionary.php
Dictionary.keys
public function keys() { $count = $this->count()->toNative(); $keysArray = new \SplFixedArray($count); foreach ($this->items as $key => $item) { $keysArray->offsetSet($key, $item->getKey()); } return new Collection($keysArray); }
php
public function keys() { $count = $this->count()->toNative(); $keysArray = new \SplFixedArray($count); foreach ($this->items as $key => $item) { $keysArray->offsetSet($key, $item->getKey()); } return new Collection($keysArray); }
[ "public", "function", "keys", "(", ")", "{", "$", "count", "=", "$", "this", "->", "count", "(", ")", "->", "toNative", "(", ")", ";", "$", "keysArray", "=", "new", "\\", "SplFixedArray", "(", "$", "count", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "keysArray", "->", "offsetSet", "(", "$", "key", ",", "$", "item", "->", "getKey", "(", ")", ")", ";", "}", "return", "new", "Collection", "(", "$", "keysArray", ")", ";", "}" ]
Returns a Collection of the keys @return Collection
[ "Returns", "a", "Collection", "of", "the", "keys" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Structure/Dictionary.php#L60-L70
train
cubicmushroom/valueobjects
src/Structure/Dictionary.php
Dictionary.values
public function values() { $count = $this->count()->toNative(); $valuesArray = new \SplFixedArray($count); foreach ($this->items as $key => $item) { $valuesArray->offsetSet($key, $item->getValue()); } return new Collection($valuesArray); }
php
public function values() { $count = $this->count()->toNative(); $valuesArray = new \SplFixedArray($count); foreach ($this->items as $key => $item) { $valuesArray->offsetSet($key, $item->getValue()); } return new Collection($valuesArray); }
[ "public", "function", "values", "(", ")", "{", "$", "count", "=", "$", "this", "->", "count", "(", ")", "->", "toNative", "(", ")", ";", "$", "valuesArray", "=", "new", "\\", "SplFixedArray", "(", "$", "count", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "valuesArray", "->", "offsetSet", "(", "$", "key", ",", "$", "item", "->", "getValue", "(", ")", ")", ";", "}", "return", "new", "Collection", "(", "$", "valuesArray", ")", ";", "}" ]
Returns a Collection of the values @return Collection
[ "Returns", "a", "Collection", "of", "the", "values" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Structure/Dictionary.php#L77-L87
train
larapulse/support
src/Handlers/RegEx.php
RegEx.prepare
public static function prepare(string $string, $quotes = '/') : string { $string = $quotes ? preg_quote($string, $quotes) : $string; return str_replace( array_keys(self::REGEX_CHARS_REPLACEMENT), array_values(self::REGEX_CHARS_REPLACEMENT), $string ); }
php
public static function prepare(string $string, $quotes = '/') : string { $string = $quotes ? preg_quote($string, $quotes) : $string; return str_replace( array_keys(self::REGEX_CHARS_REPLACEMENT), array_values(self::REGEX_CHARS_REPLACEMENT), $string ); }
[ "public", "static", "function", "prepare", "(", "string", "$", "string", ",", "$", "quotes", "=", "'/'", ")", ":", "string", "{", "$", "string", "=", "$", "quotes", "?", "preg_quote", "(", "$", "string", ",", "$", "quotes", ")", ":", "$", "string", ";", "return", "str_replace", "(", "array_keys", "(", "self", "::", "REGEX_CHARS_REPLACEMENT", ")", ",", "array_values", "(", "self", "::", "REGEX_CHARS_REPLACEMENT", ")", ",", "$", "string", ")", ";", "}" ]
Prepare string to be safety used in regex @param string $string @param string $quotes @return string
[ "Prepare", "string", "to", "be", "safety", "used", "in", "regex" ]
601ee3fd6967be669afe081322340c82c7edf32d
https://github.com/larapulse/support/blob/601ee3fd6967be669afe081322340c82c7edf32d/src/Handlers/RegEx.php#L38-L47
train
ekyna/RequireJsBundle
Twig/RequireJsExtension.php
RequireJsExtension.renderRequireJs
public function renderRequireJs($compressed = true) { if ($compressed && !$this->buildFileExists()) { // TODO throw exception ? $compressed = false; } return $this->template->render([ 'compressed' => $compressed, 'build_path' => $this->config['build_path'], 'config' => $this->provider->getMainConfig(), ]); }
php
public function renderRequireJs($compressed = true) { if ($compressed && !$this->buildFileExists()) { // TODO throw exception ? $compressed = false; } return $this->template->render([ 'compressed' => $compressed, 'build_path' => $this->config['build_path'], 'config' => $this->provider->getMainConfig(), ]); }
[ "public", "function", "renderRequireJs", "(", "$", "compressed", "=", "true", ")", "{", "if", "(", "$", "compressed", "&&", "!", "$", "this", "->", "buildFileExists", "(", ")", ")", "{", "// TODO throw exception ?", "$", "compressed", "=", "false", ";", "}", "return", "$", "this", "->", "template", "->", "render", "(", "[", "'compressed'", "=>", "$", "compressed", ",", "'build_path'", "=>", "$", "this", "->", "config", "[", "'build_path'", "]", ",", "'config'", "=>", "$", "this", "->", "provider", "->", "getMainConfig", "(", ")", ",", "]", ")", ";", "}" ]
Renders the RequireJs initialisation script. @param bool $compressed @return string
[ "Renders", "the", "RequireJs", "initialisation", "script", "." ]
2b746d25c17487838447d72a03d1050819bcf66a
https://github.com/ekyna/RequireJsBundle/blob/2b746d25c17487838447d72a03d1050819bcf66a/Twig/RequireJsExtension.php#L68-L80
train
naucon/Utility
src/ArrayMergeAbstract.php
ArrayMergeAbstract.setDeviation
protected function setDeviation($mergedArray) { if (is_array($this->getDeviationArray1()) && count($this->getDeviationArray1()) > 0 ) { $this->setDeviationArray2($this->deviationArray($this->getDeviationArray1(), $mergedArray)); } else { $this->setDeviationArray1($this->deviationArray($this->getDefaultArray(), $mergedArray)); } }
php
protected function setDeviation($mergedArray) { if (is_array($this->getDeviationArray1()) && count($this->getDeviationArray1()) > 0 ) { $this->setDeviationArray2($this->deviationArray($this->getDeviationArray1(), $mergedArray)); } else { $this->setDeviationArray1($this->deviationArray($this->getDefaultArray(), $mergedArray)); } }
[ "protected", "function", "setDeviation", "(", "$", "mergedArray", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "getDeviationArray1", "(", ")", ")", "&&", "count", "(", "$", "this", "->", "getDeviationArray1", "(", ")", ")", ">", "0", ")", "{", "$", "this", "->", "setDeviationArray2", "(", "$", "this", "->", "deviationArray", "(", "$", "this", "->", "getDeviationArray1", "(", ")", ",", "$", "mergedArray", ")", ")", ";", "}", "else", "{", "$", "this", "->", "setDeviationArray1", "(", "$", "this", "->", "deviationArray", "(", "$", "this", "->", "getDefaultArray", "(", ")", ",", "$", "mergedArray", ")", ")", ";", "}", "}" ]
set deviation arrays @param array $mergedArray merged array @return void
[ "set", "deviation", "arrays" ]
d225bb5d09d82400917f710c9d502949a66442c4
https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/ArrayMergeAbstract.php#L221-L230
train
Wedeto/DB
src/Model.php
Model.getDB
public function getDB($db = null) { if (null !== $db && !($db instanceof DB)) throw new InvalidTypeException("Invalid database"); return $db ?: $this->_source_db ?: DI::getInjector()->getInstance(DB::class); }
php
public function getDB($db = null) { if (null !== $db && !($db instanceof DB)) throw new InvalidTypeException("Invalid database"); return $db ?: $this->_source_db ?: DI::getInjector()->getInstance(DB::class); }
[ "public", "function", "getDB", "(", "$", "db", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "db", "&&", "!", "(", "$", "db", "instanceof", "DB", ")", ")", "throw", "new", "InvalidTypeException", "(", "\"Invalid database\"", ")", ";", "return", "$", "db", "?", ":", "$", "this", "->", "_source_db", "?", ":", "DI", "::", "getInjector", "(", ")", "->", "getInstance", "(", "DB", "::", "class", ")", ";", "}" ]
Get a suitable database. Either the provided database argument, or when null, the source database. If source database is also null, the default database is returned. @return Wedeto\DB\DB A suitable database
[ "Get", "a", "suitable", "database", ".", "Either", "the", "provided", "database", "argument", "or", "when", "null", "the", "source", "database", ".", "If", "source", "database", "is", "also", "null", "the", "default", "database", "is", "returned", "." ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Model.php#L90-L95
train
Wedeto/DB
src/Model.php
Model.insert
public function insert($db = null) { $this->getDAO($this->getDB($db))->save($this); return $this; }
php
public function insert($db = null) { $this->getDAO($this->getDB($db))->save($this); return $this; }
[ "public", "function", "insert", "(", "$", "db", "=", "null", ")", "{", "$", "this", "->", "getDAO", "(", "$", "this", "->", "getDB", "(", "$", "db", ")", ")", "->", "save", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Insert the record to the database @return Wedeto\DB\Model the saved object
[ "Insert", "the", "record", "to", "the", "database" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Model.php#L115-L119
train
Wedeto/DB
src/Model.php
Model.delete
public function delete($db = null) { $this->getDAO($this->getDB($db))->delete($this); return $this; }
php
public function delete($db = null) { $this->getDAO($this->getDB($db))->delete($this); return $this; }
[ "public", "function", "delete", "(", "$", "db", "=", "null", ")", "{", "$", "this", "->", "getDAO", "(", "$", "this", "->", "getDB", "(", "$", "db", ")", ")", "->", "delete", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Remove the current record from the database it was retrieved from.
[ "Remove", "the", "current", "record", "from", "the", "database", "it", "was", "retrieved", "from", "." ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Model.php#L124-L128
train
Wedeto/DB
src/Model.php
Model.setSourceDB
public function setSourceDB(DB $db) { if ($db === null) throw new \InvalidArgumentException("Source database must not be null"); $this->_source_db = $db; return $this; }
php
public function setSourceDB(DB $db) { if ($db === null) throw new \InvalidArgumentException("Source database must not be null"); $this->_source_db = $db; return $this; }
[ "public", "function", "setSourceDB", "(", "DB", "$", "db", ")", "{", "if", "(", "$", "db", "===", "null", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Source database must not be null\"", ")", ";", "$", "this", "->", "_source_db", "=", "$", "db", ";", "return", "$", "this", ";", "}" ]
Set the database this object came from @param Wedeto\DB\DB $db The database connection @return Wedeto\DB\DAO Provides fluent interface
[ "Set", "the", "database", "this", "object", "came", "from" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Model.php#L136-L142
train
Wedeto/DB
src/Model.php
Model.assignRecord
public function assignRecord(array $record, DB $database) { $dao = $this->getDAO(); $table = $dao->getTable($database); $pkey = $table->getPrimaryColumns(); if ($pkey !== null) { $this->_id = array(); foreach ($pkey as $col) $this->_id[$col->getName()] = $record[$col->getName()]; } else $this->_id = null; $this->_record = $record; $this->_changed = array(); $this->setSourceDB($database); $this->init(); $columns = $table->getColumns($database); foreach ($columns as $name => $def) { if (!array_key_exists($name, $this->_record)) continue; $this->_record[$name] = $def->afterFetchFilter($this->_record[$name]); // Synchronize local variables if (property_exists($this, $name)) $this->$name = $this->_record[$name]; } return $this; }
php
public function assignRecord(array $record, DB $database) { $dao = $this->getDAO(); $table = $dao->getTable($database); $pkey = $table->getPrimaryColumns(); if ($pkey !== null) { $this->_id = array(); foreach ($pkey as $col) $this->_id[$col->getName()] = $record[$col->getName()]; } else $this->_id = null; $this->_record = $record; $this->_changed = array(); $this->setSourceDB($database); $this->init(); $columns = $table->getColumns($database); foreach ($columns as $name => $def) { if (!array_key_exists($name, $this->_record)) continue; $this->_record[$name] = $def->afterFetchFilter($this->_record[$name]); // Synchronize local variables if (property_exists($this, $name)) $this->$name = $this->_record[$name]; } return $this; }
[ "public", "function", "assignRecord", "(", "array", "$", "record", ",", "DB", "$", "database", ")", "{", "$", "dao", "=", "$", "this", "->", "getDAO", "(", ")", ";", "$", "table", "=", "$", "dao", "->", "getTable", "(", "$", "database", ")", ";", "$", "pkey", "=", "$", "table", "->", "getPrimaryColumns", "(", ")", ";", "if", "(", "$", "pkey", "!==", "null", ")", "{", "$", "this", "->", "_id", "=", "array", "(", ")", ";", "foreach", "(", "$", "pkey", "as", "$", "col", ")", "$", "this", "->", "_id", "[", "$", "col", "->", "getName", "(", ")", "]", "=", "$", "record", "[", "$", "col", "->", "getName", "(", ")", "]", ";", "}", "else", "$", "this", "->", "_id", "=", "null", ";", "$", "this", "->", "_record", "=", "$", "record", ";", "$", "this", "->", "_changed", "=", "array", "(", ")", ";", "$", "this", "->", "setSourceDB", "(", "$", "database", ")", ";", "$", "this", "->", "init", "(", ")", ";", "$", "columns", "=", "$", "table", "->", "getColumns", "(", "$", "database", ")", ";", "foreach", "(", "$", "columns", "as", "$", "name", "=>", "$", "def", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_record", ")", ")", "continue", ";", "$", "this", "->", "_record", "[", "$", "name", "]", "=", "$", "def", "->", "afterFetchFilter", "(", "$", "this", "->", "_record", "[", "$", "name", "]", ")", ";", "// Synchronize local variables", "if", "(", "property_exists", "(", "$", "this", ",", "$", "name", ")", ")", "$", "this", "->", "$", "name", "=", "$", "this", "->", "_record", "[", "$", "name", "]", ";", "}", "return", "$", "this", ";", "}" ]
Assign the provided record to this object. @param array $record The record obtained from the database. @param Wedeto\DB\DB $database The database this record comes from @return Wedeto\DB\DAO Provides fluent interface
[ "Assign", "the", "provided", "record", "to", "this", "object", "." ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Model.php#L158-L190
train
Wedeto/DB
src/Model.php
Model.setID
public function setID($id) { $dao = $this->getDAO(); $pkey = $dao->getPrimaryKey(); if (count($pkey) === 1 && is_scalar($id)) { $pcol = reset($pkey); $this->setField($pcol->getName(), $id); } elseif (is_array($id) && array_keys($id) === array_keys($pkey)) { foreach ($pkey as $name => $def) { $this->setField($name, $id[$name]); } $this->_id = $id; } else { throw new InvalidTypeException("Provided ID does not match primary key"); } return $this; }
php
public function setID($id) { $dao = $this->getDAO(); $pkey = $dao->getPrimaryKey(); if (count($pkey) === 1 && is_scalar($id)) { $pcol = reset($pkey); $this->setField($pcol->getName(), $id); } elseif (is_array($id) && array_keys($id) === array_keys($pkey)) { foreach ($pkey as $name => $def) { $this->setField($name, $id[$name]); } $this->_id = $id; } else { throw new InvalidTypeException("Provided ID does not match primary key"); } return $this; }
[ "public", "function", "setID", "(", "$", "id", ")", "{", "$", "dao", "=", "$", "this", "->", "getDAO", "(", ")", ";", "$", "pkey", "=", "$", "dao", "->", "getPrimaryKey", "(", ")", ";", "if", "(", "count", "(", "$", "pkey", ")", "===", "1", "&&", "is_scalar", "(", "$", "id", ")", ")", "{", "$", "pcol", "=", "reset", "(", "$", "pkey", ")", ";", "$", "this", "->", "setField", "(", "$", "pcol", "->", "getName", "(", ")", ",", "$", "id", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "id", ")", "&&", "array_keys", "(", "$", "id", ")", "===", "array_keys", "(", "$", "pkey", ")", ")", "{", "foreach", "(", "$", "pkey", "as", "$", "name", "=>", "$", "def", ")", "{", "$", "this", "->", "setField", "(", "$", "name", ",", "$", "id", "[", "$", "name", "]", ")", ";", "}", "$", "this", "->", "_id", "=", "$", "id", ";", "}", "else", "{", "throw", "new", "InvalidTypeException", "(", "\"Provided ID does not match primary key\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the primary key of the model instance @param mixed $id The primary key. Either a scalar value or an array for a combined primary key @return Wedeto\DB\Model Provides fluent interface
[ "Set", "the", "primary", "key", "of", "the", "model", "instance" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Model.php#L222-L245
train