repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listUserReposPaginate
public function listUserReposPaginate($authorization, $pageURL) { $instance = new listUserReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listUserReposPaginate($authorization, $pageURL) { $instance = new listUserReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listUserReposPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listUserReposPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listUserReposPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listUserReposPaginate The new operation
[ "listUserReposPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2208-L2211
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listOrgReposPaginate
public function listOrgReposPaginate($authorization, $pageURL) { $instance = new listOrgReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listOrgReposPaginate($authorization, $pageURL) { $instance = new listOrgReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listOrgReposPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listOrgReposPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listOrgReposPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listOrgReposPaginate The new operation
[ "listOrgReposPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2225-L2228
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listPublicReposPaginate
public function listPublicReposPaginate($authorization, $pageURL) { $instance = new listPublicReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listPublicReposPaginate($authorization, $pageURL) { $instance = new listPublicReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listPublicReposPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listPublicReposPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listPublicReposPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listPublicReposPaginate The new operation
[ "listPublicReposPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2242-L2245
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.getRepoPaginate
public function getRepoPaginate($authorization, $pageURL) { $instance = new getRepoPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function getRepoPaginate($authorization, $pageURL) { $instance = new getRepoPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "getRepoPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "getRepoPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
getRepoPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\getRepoPaginate The new operation
[ "getRepoPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2259-L2262
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listRepoContributorsPaginate
public function listRepoContributorsPaginate($authorization, $pageURL) { $instance = new listRepoContributorsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listRepoContributorsPaginate($authorization, $pageURL) { $instance = new listRepoContributorsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listRepoContributorsPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listRepoContributorsPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listRepoContributorsPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listRepoContributorsPaginate The new operation
[ "listRepoContributorsPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2276-L2279
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listRepoLanguagesPaginate
public function listRepoLanguagesPaginate($authorization, $pageURL) { $instance = new listRepoLanguagesPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listRepoLanguagesPaginate($authorization, $pageURL) { $instance = new listRepoLanguagesPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listRepoLanguagesPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listRepoLanguagesPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listRepoLanguagesPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listRepoLanguagesPaginate The new operation
[ "listRepoLanguagesPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2293-L2296
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listRepoTeamsPaginate
public function listRepoTeamsPaginate($authorization, $pageURL) { $instance = new listRepoTeamsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listRepoTeamsPaginate($authorization, $pageURL) { $instance = new listRepoTeamsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listRepoTeamsPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listRepoTeamsPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listRepoTeamsPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listRepoTeamsPaginate The new operation
[ "listRepoTeamsPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2310-L2313
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listRepoTagsPaginate
public function listRepoTagsPaginate($authorization, $pageURL) { $instance = new listRepoTagsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listRepoTagsPaginate($authorization, $pageURL) { $instance = new listRepoTagsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listRepoTagsPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listRepoTagsPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listRepoTagsPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listRepoTagsPaginate The new operation
[ "listRepoTagsPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2327-L2330
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listRepoBranchesPaginate
public function listRepoBranchesPaginate($authorization, $pageURL) { $instance = new listRepoBranchesPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listRepoBranchesPaginate($authorization, $pageURL) { $instance = new listRepoBranchesPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listRepoBranchesPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listRepoBranchesPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listRepoBranchesPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listRepoBranchesPaginate The new operation
[ "listRepoBranchesPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2344-L2347
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.getRepoBranchPaginate
public function getRepoBranchPaginate($authorization, $pageURL) { $instance = new getRepoBranchPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function getRepoBranchPaginate($authorization, $pageURL) { $instance = new getRepoBranchPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "getRepoBranchPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "getRepoBranchPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
getRepoBranchPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\getRepoBranchPaginate The new operation
[ "getRepoBranchPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2361-L2364
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.searchReposPaginate
public function searchReposPaginate($authorization, $pageURL) { $instance = new searchReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function searchReposPaginate($authorization, $pageURL) { $instance = new searchReposPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "searchReposPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "searchReposPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
searchReposPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\searchReposPaginate The new operation
[ "searchReposPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2378-L2381
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.listUserEmailsPaginate
public function listUserEmailsPaginate($authorization, $pageURL) { $instance = new listUserEmailsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function listUserEmailsPaginate($authorization, $pageURL) { $instance = new listUserEmailsPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "listUserEmailsPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "listUserEmailsPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
listUserEmailsPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\listUserEmailsPaginate The new operation
[ "listUserEmailsPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2395-L2398
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.getUserPaginate
public function getUserPaginate($authorization, $pageURL) { $instance = new getUserPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function getUserPaginate($authorization, $pageURL) { $instance = new getUserPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "getUserPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "getUserPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
getUserPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\getUserPaginate The new operation
[ "getUserPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2412-L2415
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.getSelfUserPaginate
public function getSelfUserPaginate($authorization, $pageURL) { $instance = new getSelfUserPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
php
public function getSelfUserPaginate($authorization, $pageURL) { $instance = new getSelfUserPaginate($this, $authorization, $this->getUserAgent(), $pageURL); return $instance; }
[ "public", "function", "getSelfUserPaginate", "(", "$", "authorization", ",", "$", "pageURL", ")", "{", "$", "instance", "=", "new", "getSelfUserPaginate", "(", "$", "this", ",", "$", "authorization", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "pageURL", ")", ";", "return", "$", "instance", ";", "}" ]
getSelfUserPaginate @param GithubService\AuthToken $Authorization The token to use for the request. This should either be an a complete token in the format appropriate format e.g. 'token 123567890' for an oauth token, or '"Basic ".base64_encode($username.":".$password)"' for a Basic token or anything that can be cast to a string in the correct format e.g. an \ArtaxServiceBuilder\BasicAuthToken object. @param mixed $pageURL @return \GithubService\Operation\getSelfUserPaginate The new operation
[ "getSelfUserPaginate" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2429-L2432
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.execute
public function execute(\Amp\Artax\Request $request, \ArtaxServiceBuilder\Operation $operation) { $originalRequest = clone $request; $cachingHeaders = $this->responseCache->getCachingHeaders($request); $request->setAllHeaders($cachingHeaders); $promise = $this->client->request($request); $response = \Amp\wait($promise, $this->reactor); if ($response) { $operation->setResponse($response); $operation->setOriginalResponse($response); } if ($operation->shouldResponseBeCached($response)) { $this->responseCache->storeResponse($originalRequest, $response); } if ($operation->shouldUseCachedResponse($response)) { $cachedResponse = $this->responseCache->getResponse($originalRequest); if ($cachedResponse) { $response = $cachedResponse; $operation->setResponse($response); } //@TODO This code should only be reached if the cache entry was deleted //so throw an exception? Or just leave the 304 to error? } $exception = $operation->translateResponseToException($response); if ($exception) { throw $exception; } return $response; }
php
public function execute(\Amp\Artax\Request $request, \ArtaxServiceBuilder\Operation $operation) { $originalRequest = clone $request; $cachingHeaders = $this->responseCache->getCachingHeaders($request); $request->setAllHeaders($cachingHeaders); $promise = $this->client->request($request); $response = \Amp\wait($promise, $this->reactor); if ($response) { $operation->setResponse($response); $operation->setOriginalResponse($response); } if ($operation->shouldResponseBeCached($response)) { $this->responseCache->storeResponse($originalRequest, $response); } if ($operation->shouldUseCachedResponse($response)) { $cachedResponse = $this->responseCache->getResponse($originalRequest); if ($cachedResponse) { $response = $cachedResponse; $operation->setResponse($response); } //@TODO This code should only be reached if the cache entry was deleted //so throw an exception? Or just leave the 304 to error? } $exception = $operation->translateResponseToException($response); if ($exception) { throw $exception; } return $response; }
[ "public", "function", "execute", "(", "\\", "Amp", "\\", "Artax", "\\", "Request", "$", "request", ",", "\\", "ArtaxServiceBuilder", "\\", "Operation", "$", "operation", ")", "{", "$", "originalRequest", "=", "clone", "$", "request", ";", "$", "cachingHeaders", "=", "$", "this", "->", "responseCache", "->", "getCachingHeaders", "(", "$", "request", ")", ";", "$", "request", "->", "setAllHeaders", "(", "$", "cachingHeaders", ")", ";", "$", "promise", "=", "$", "this", "->", "client", "->", "request", "(", "$", "request", ")", ";", "$", "response", "=", "\\", "Amp", "\\", "wait", "(", "$", "promise", ",", "$", "this", "->", "reactor", ")", ";", "if", "(", "$", "response", ")", "{", "$", "operation", "->", "setResponse", "(", "$", "response", ")", ";", "$", "operation", "->", "setOriginalResponse", "(", "$", "response", ")", ";", "}", "if", "(", "$", "operation", "->", "shouldResponseBeCached", "(", "$", "response", ")", ")", "{", "$", "this", "->", "responseCache", "->", "storeResponse", "(", "$", "originalRequest", ",", "$", "response", ")", ";", "}", "if", "(", "$", "operation", "->", "shouldUseCachedResponse", "(", "$", "response", ")", ")", "{", "$", "cachedResponse", "=", "$", "this", "->", "responseCache", "->", "getResponse", "(", "$", "originalRequest", ")", ";", "if", "(", "$", "cachedResponse", ")", "{", "$", "response", "=", "$", "cachedResponse", ";", "$", "operation", "->", "setResponse", "(", "$", "response", ")", ";", "}", "//@TODO This code should only be reached if the cache entry was deleted", "//so throw an exception? Or just leave the 304 to error?", "}", "$", "exception", "=", "$", "operation", "->", "translateResponseToException", "(", "$", "response", ")", ";", "if", "(", "$", "exception", ")", "{", "throw", "$", "exception", ";", "}", "return", "$", "response", ";", "}" ]
execute Sends a request to the API synchronously @param $request \Amp\Artax\Request The request to send. @param $operation \ArtaxServiceBuilder\Operation The response that is called the execute. @return \Amp\Artax\Response The response from Artax
[ "execute" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2455-L2488
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.executeAsync
public function executeAsync(\Amp\Artax\Request $request, \ArtaxServiceBuilder\Operation $operation, callable $callback) { $originalRequest = clone $request; $cachingHeaders = $this->responseCache->getCachingHeaders($request); $request->setAllHeaders($cachingHeaders); $promise = $this->client->request($request); $promise->when(function(\Exception $error = null, Response $response = null) use ($originalRequest, $callback, $operation) { if ($response) { $operation->setResponse($response); $operation->setOriginalResponse($response); } if($error) { $callback($error, null, null); return; } if ($operation->shouldResponseBeCached($response)) { $this->responseCache->storeResponse($originalRequest, $response); } if ($operation->shouldUseCachedResponse($response)) { $cachedResponse = $this->responseCache->getResponse($originalRequest); if ($cachedResponse) { $response = $cachedResponse; $operation->setResponse($response); } } $responseException = $operation->translateResponseToException($response); if ($responseException) { $callback($responseException, null, $response); return; } if ($operation->shouldResponseBeProcessed($response)) { try { $parsedResponse = $operation->processResponse($response); $callback(null, $parsedResponse, $response); } catch(\Exception $e) { $exception = new ProcessResponseException("Exception parsing response: ".$e->getMessage(), 0, $e); $callback($exception, null, $response); } } else { $callback(null, null, $response); } }); return $promise; }
php
public function executeAsync(\Amp\Artax\Request $request, \ArtaxServiceBuilder\Operation $operation, callable $callback) { $originalRequest = clone $request; $cachingHeaders = $this->responseCache->getCachingHeaders($request); $request->setAllHeaders($cachingHeaders); $promise = $this->client->request($request); $promise->when(function(\Exception $error = null, Response $response = null) use ($originalRequest, $callback, $operation) { if ($response) { $operation->setResponse($response); $operation->setOriginalResponse($response); } if($error) { $callback($error, null, null); return; } if ($operation->shouldResponseBeCached($response)) { $this->responseCache->storeResponse($originalRequest, $response); } if ($operation->shouldUseCachedResponse($response)) { $cachedResponse = $this->responseCache->getResponse($originalRequest); if ($cachedResponse) { $response = $cachedResponse; $operation->setResponse($response); } } $responseException = $operation->translateResponseToException($response); if ($responseException) { $callback($responseException, null, $response); return; } if ($operation->shouldResponseBeProcessed($response)) { try { $parsedResponse = $operation->processResponse($response); $callback(null, $parsedResponse, $response); } catch(\Exception $e) { $exception = new ProcessResponseException("Exception parsing response: ".$e->getMessage(), 0, $e); $callback($exception, null, $response); } } else { $callback(null, null, $response); } }); return $promise; }
[ "public", "function", "executeAsync", "(", "\\", "Amp", "\\", "Artax", "\\", "Request", "$", "request", ",", "\\", "ArtaxServiceBuilder", "\\", "Operation", "$", "operation", ",", "callable", "$", "callback", ")", "{", "$", "originalRequest", "=", "clone", "$", "request", ";", "$", "cachingHeaders", "=", "$", "this", "->", "responseCache", "->", "getCachingHeaders", "(", "$", "request", ")", ";", "$", "request", "->", "setAllHeaders", "(", "$", "cachingHeaders", ")", ";", "$", "promise", "=", "$", "this", "->", "client", "->", "request", "(", "$", "request", ")", ";", "$", "promise", "->", "when", "(", "function", "(", "\\", "Exception", "$", "error", "=", "null", ",", "Response", "$", "response", "=", "null", ")", "use", "(", "$", "originalRequest", ",", "$", "callback", ",", "$", "operation", ")", "{", "if", "(", "$", "response", ")", "{", "$", "operation", "->", "setResponse", "(", "$", "response", ")", ";", "$", "operation", "->", "setOriginalResponse", "(", "$", "response", ")", ";", "}", "if", "(", "$", "error", ")", "{", "$", "callback", "(", "$", "error", ",", "null", ",", "null", ")", ";", "return", ";", "}", "if", "(", "$", "operation", "->", "shouldResponseBeCached", "(", "$", "response", ")", ")", "{", "$", "this", "->", "responseCache", "->", "storeResponse", "(", "$", "originalRequest", ",", "$", "response", ")", ";", "}", "if", "(", "$", "operation", "->", "shouldUseCachedResponse", "(", "$", "response", ")", ")", "{", "$", "cachedResponse", "=", "$", "this", "->", "responseCache", "->", "getResponse", "(", "$", "originalRequest", ")", ";", "if", "(", "$", "cachedResponse", ")", "{", "$", "response", "=", "$", "cachedResponse", ";", "$", "operation", "->", "setResponse", "(", "$", "response", ")", ";", "}", "}", "$", "responseException", "=", "$", "operation", "->", "translateResponseToException", "(", "$", "response", ")", ";", "if", "(", "$", "responseException", ")", "{", "$", "callback", "(", "$", "responseException", ",", "null", ",", "$", "response", ")", ";", "return", ";", "}", "if", "(", "$", "operation", "->", "shouldResponseBeProcessed", "(", "$", "response", ")", ")", "{", "try", "{", "$", "parsedResponse", "=", "$", "operation", "->", "processResponse", "(", "$", "response", ")", ";", "$", "callback", "(", "null", ",", "$", "parsedResponse", ",", "$", "response", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "exception", "=", "new", "ProcessResponseException", "(", "\"Exception parsing response: \"", ".", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "$", "callback", "(", "$", "exception", ",", "null", ",", "$", "response", ")", ";", "}", "}", "else", "{", "$", "callback", "(", "null", ",", "null", ",", "$", "response", ")", ";", "}", "}", ")", ";", "return", "$", "promise", ";", "}" ]
executeAsync Execute an operation asynchronously. @param \ArtaxServiceBuilder\Operation $operation The operation to perform @param callable $callback The callback to call on completion/response. The signature of the method should be: function( \Exception $error = null, // null if no error $parsedData = null, //The parsed operation data i.e. same type as responseClass of the operation. \Amp\Artax\Response $response = null //The response received or null if the request completely failed. ) @return \Amp\Promise A promise to resolve the call at some time.
[ "executeAsync" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2507-L2558
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.shouldResponseBeCached
public function shouldResponseBeCached(\Amp\Artax\Response $response) { $status = $response->getStatus(); if ($status == 200) { return true; } return false; }
php
public function shouldResponseBeCached(\Amp\Artax\Response $response) { $status = $response->getStatus(); if ($status == 200) { return true; } return false; }
[ "public", "function", "shouldResponseBeCached", "(", "\\", "Amp", "\\", "Artax", "\\", "Response", "$", "response", ")", "{", "$", "status", "=", "$", "response", "->", "getStatus", "(", ")", ";", "if", "(", "$", "status", "==", "200", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determine whether the response should be cached. @return boolean
[ "Determine", "whether", "the", "response", "should", "be", "cached", "." ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2574-L2581
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.translateResponseToException
public function translateResponseToException(\Amp\Artax\Response $response) { $status = $response->getStatus(); if ($status < 200 || $status >= 300) { return new BadResponseException( "Status $status is not treated as OK.", $response ); } return null; }
php
public function translateResponseToException(\Amp\Artax\Response $response) { $status = $response->getStatus(); if ($status < 200 || $status >= 300) { return new BadResponseException( "Status $status is not treated as OK.", $response ); } return null; }
[ "public", "function", "translateResponseToException", "(", "\\", "Amp", "\\", "Artax", "\\", "Response", "$", "response", ")", "{", "$", "status", "=", "$", "response", "->", "getStatus", "(", ")", ";", "if", "(", "$", "status", "<", "200", "||", "$", "status", ">=", "300", ")", "{", "return", "new", "BadResponseException", "(", "\"Status $status is not treated as OK.\"", ",", "$", "response", ")", ";", "}", "return", "null", ";", "}" ]
Inspect the response and return an exception if it is an error response. * Exceptions should extend \ArtaxServiceBuilder\BadResponseException @return BadResponseException
[ "Inspect", "the", "response", "and", "return", "an", "exception", "if", "it", "is", "an", "error", "response", ".", "*", "Exceptions", "should", "extend", "\\", "ArtaxServiceBuilder", "\\", "BadResponseException" ]
train
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2604-L2614
roshangara/parser
src/Parser.php
Parser.fromXml
public function fromXml(string $xml): array { if (!$this->isEmptyValue($xml)) { libxml_use_internal_errors(true); // convert string to xml object $result = simplexml_load_string("$xml", 'SimpleXMLElement', LIBXML_NOCDATA); if ($result) { return $this->fromClass($result); } else { foreach (libxml_get_errors() as $error) { // if don`t have container add that`s if ($error->code == 5) { $this->errors = []; // append container and parse again return $this->fromXml("<DATA>$xml</DATA>"); } else $this->setError($error->code, $error->message); } } } return $this->result; }
php
public function fromXml(string $xml): array { if (!$this->isEmptyValue($xml)) { libxml_use_internal_errors(true); // convert string to xml object $result = simplexml_load_string("$xml", 'SimpleXMLElement', LIBXML_NOCDATA); if ($result) { return $this->fromClass($result); } else { foreach (libxml_get_errors() as $error) { // if don`t have container add that`s if ($error->code == 5) { $this->errors = []; // append container and parse again return $this->fromXml("<DATA>$xml</DATA>"); } else $this->setError($error->code, $error->message); } } } return $this->result; }
[ "public", "function", "fromXml", "(", "string", "$", "xml", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isEmptyValue", "(", "$", "xml", ")", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "// convert string to xml object", "$", "result", "=", "simplexml_load_string", "(", "\"$xml\"", ",", "'SimpleXMLElement'", ",", "LIBXML_NOCDATA", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "this", "->", "fromClass", "(", "$", "result", ")", ";", "}", "else", "{", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "{", "// if don`t have container add that`s", "if", "(", "$", "error", "->", "code", "==", "5", ")", "{", "$", "this", "->", "errors", "=", "[", "]", ";", "// append container and parse again", "return", "$", "this", "->", "fromXml", "(", "\"<DATA>$xml</DATA>\"", ")", ";", "}", "else", "$", "this", "->", "setError", "(", "$", "error", "->", "code", ",", "$", "error", "->", "message", ")", ";", "}", "}", "}", "return", "$", "this", "->", "result", ";", "}" ]
Convert xml to array @param string $xml @return array|mixed
[ "Convert", "xml", "to", "array" ]
train
https://github.com/roshangara/parser/blob/24c6c3781fd4416fefb5218daad765b9edbcaa76/src/Parser.php#L27-L57
roshangara/parser
src/Parser.php
Parser.fromXSD
public function fromXSD($xsd): array { if (!$this->isEmptyValue($xsd)) { return $this->fromXml($xsd->output); } return $this->result; }
php
public function fromXSD($xsd): array { if (!$this->isEmptyValue($xsd)) { return $this->fromXml($xsd->output); } return $this->result; }
[ "public", "function", "fromXSD", "(", "$", "xsd", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isEmptyValue", "(", "$", "xsd", ")", ")", "{", "return", "$", "this", "->", "fromXml", "(", "$", "xsd", "->", "output", ")", ";", "}", "return", "$", "this", "->", "result", ";", "}" ]
Convert class to array @param $xsd @return array|mixed
[ "Convert", "class", "to", "array" ]
train
https://github.com/roshangara/parser/blob/24c6c3781fd4416fefb5218daad765b9edbcaa76/src/Parser.php#L81-L89
roshangara/parser
src/Parser.php
Parser.fromJson
public function fromJson(string $json): array { if (!$this->isEmptyValue($json)) { if ($decode = json_decode(trim($json), true) and json_last_error() == JSON_ERROR_NONE) $this->result = $decode; else $this->setError(json_last_error(), json_last_error_msg()); } return $this->result; }
php
public function fromJson(string $json): array { if (!$this->isEmptyValue($json)) { if ($decode = json_decode(trim($json), true) and json_last_error() == JSON_ERROR_NONE) $this->result = $decode; else $this->setError(json_last_error(), json_last_error_msg()); } return $this->result; }
[ "public", "function", "fromJson", "(", "string", "$", "json", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isEmptyValue", "(", "$", "json", ")", ")", "{", "if", "(", "$", "decode", "=", "json_decode", "(", "trim", "(", "$", "json", ")", ",", "true", ")", "and", "json_last_error", "(", ")", "==", "JSON_ERROR_NONE", ")", "$", "this", "->", "result", "=", "$", "decode", ";", "else", "$", "this", "->", "setError", "(", "json_last_error", "(", ")", ",", "json_last_error_msg", "(", ")", ")", ";", "}", "return", "$", "this", "->", "result", ";", "}" ]
Convert json to array @param string $json @return array|mixed
[ "Convert", "json", "to", "array" ]
train
https://github.com/roshangara/parser/blob/24c6c3781fd4416fefb5218daad765b9edbcaa76/src/Parser.php#L112-L123
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.setSourceList
protected function setSourceList(array $sourceParameters, array $globalParameters = array()) { // Creating as many Source instances as configured in the configuration file foreach ($sourceParameters as $key => $parameters) { if (!isset($parameters['type'])) { throw new Exception\BadProxyConfigurationException( sprintf("Missing parameters 'type' for remote source configuration '%s'", $key) ); } else { // Getting the type from the configuration $type = $parameters['type']; // Catching exception thrown in the SourceFactory try { // Getting Source instance from factory $source = $this->sourceFactory->getSourceInstance($type, $key, $parameters, $globalParameters); if ($source instanceof SourceInterface) { // Adding this Source instance to the list of Source instances to be processed by the Proxy $this->addSource($source); $this->sources[$key] = $source; } else { throw new Exception\BadProxyConfigurationException( sprintf( "Expected instance of 'Msl\ResourceProxy\Source\SourceInterface' but got '%s'", get_class($source) ) ); } } catch (Exception\BadSourceConfigConfigurationException $bscce) { throw new Exception\BadProxyConfigurationException( sprintf( "The following exception has been caught while generating a source object for the source '%s': %s", $key, $bscce->getMessage() ) ); } } } }
php
protected function setSourceList(array $sourceParameters, array $globalParameters = array()) { // Creating as many Source instances as configured in the configuration file foreach ($sourceParameters as $key => $parameters) { if (!isset($parameters['type'])) { throw new Exception\BadProxyConfigurationException( sprintf("Missing parameters 'type' for remote source configuration '%s'", $key) ); } else { // Getting the type from the configuration $type = $parameters['type']; // Catching exception thrown in the SourceFactory try { // Getting Source instance from factory $source = $this->sourceFactory->getSourceInstance($type, $key, $parameters, $globalParameters); if ($source instanceof SourceInterface) { // Adding this Source instance to the list of Source instances to be processed by the Proxy $this->addSource($source); $this->sources[$key] = $source; } else { throw new Exception\BadProxyConfigurationException( sprintf( "Expected instance of 'Msl\ResourceProxy\Source\SourceInterface' but got '%s'", get_class($source) ) ); } } catch (Exception\BadSourceConfigConfigurationException $bscce) { throw new Exception\BadProxyConfigurationException( sprintf( "The following exception has been caught while generating a source object for the source '%s': %s", $key, $bscce->getMessage() ) ); } } } }
[ "protected", "function", "setSourceList", "(", "array", "$", "sourceParameters", ",", "array", "$", "globalParameters", "=", "array", "(", ")", ")", "{", "// Creating as many Source instances as configured in the configuration file", "foreach", "(", "$", "sourceParameters", "as", "$", "key", "=>", "$", "parameters", ")", "{", "if", "(", "!", "isset", "(", "$", "parameters", "[", "'type'", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "BadProxyConfigurationException", "(", "sprintf", "(", "\"Missing parameters 'type' for remote source configuration '%s'\"", ",", "$", "key", ")", ")", ";", "}", "else", "{", "// Getting the type from the configuration", "$", "type", "=", "$", "parameters", "[", "'type'", "]", ";", "// Catching exception thrown in the SourceFactory", "try", "{", "// Getting Source instance from factory", "$", "source", "=", "$", "this", "->", "sourceFactory", "->", "getSourceInstance", "(", "$", "type", ",", "$", "key", ",", "$", "parameters", ",", "$", "globalParameters", ")", ";", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "// Adding this Source instance to the list of Source instances to be processed by the Proxy", "$", "this", "->", "addSource", "(", "$", "source", ")", ";", "$", "this", "->", "sources", "[", "$", "key", "]", "=", "$", "source", ";", "}", "else", "{", "throw", "new", "Exception", "\\", "BadProxyConfigurationException", "(", "sprintf", "(", "\"Expected instance of 'Msl\\ResourceProxy\\Source\\SourceInterface' but got '%s'\"", ",", "get_class", "(", "$", "source", ")", ")", ")", ";", "}", "}", "catch", "(", "Exception", "\\", "BadSourceConfigConfigurationException", "$", "bscce", ")", "{", "throw", "new", "Exception", "\\", "BadProxyConfigurationException", "(", "sprintf", "(", "\"The following exception has been caught while generating a source object for the source '%s': %s\"", ",", "$", "key", ",", "$", "bscce", "->", "getMessage", "(", ")", ")", ")", ";", "}", "}", "}", "}" ]
Creates and adds to the Source object list all the configured Source instances @param array $sourceParameters the configuration parameter array @param array $globalParameters the global configuration parameter array @throws \Msl\ResourceProxy\Exception\BadProxyConfigurationException @return void
[ "Creates", "and", "adds", "to", "the", "Source", "object", "list", "all", "the", "configured", "Source", "instances" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L171-L211
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.processResources
public function processResources() { // Fetching the sources iterator $errors = array(); foreach($this->sourcesIterator as $source) { // Processing all resources associated to the current source object if ($source instanceof SourceInterface) { try { $this->processResourcesBySource($source); } catch (Exception\PostParseException $e) { array_push($errors, $e); } catch (Exception\ResourceProxyExceptionInterface $e) { $msg = sprintf( 'General proxy error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } catch (\Exception $e) { $msg = sprintf( 'General error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } } } // If errors, we throw a global process exception if (count($errors) > 0) { throw new Exception\GlobalProcessException( $errors, sprintf( 'Errors while processing the sources for the following proxy: \'%s\'.', $this->getProxyName() ) ); } }
php
public function processResources() { // Fetching the sources iterator $errors = array(); foreach($this->sourcesIterator as $source) { // Processing all resources associated to the current source object if ($source instanceof SourceInterface) { try { $this->processResourcesBySource($source); } catch (Exception\PostParseException $e) { array_push($errors, $e); } catch (Exception\ResourceProxyExceptionInterface $e) { $msg = sprintf( 'General proxy error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } catch (\Exception $e) { $msg = sprintf( 'General error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } } } // If errors, we throw a global process exception if (count($errors) > 0) { throw new Exception\GlobalProcessException( $errors, sprintf( 'Errors while processing the sources for the following proxy: \'%s\'.', $this->getProxyName() ) ); } }
[ "public", "function", "processResources", "(", ")", "{", "// Fetching the sources iterator", "$", "errors", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "sourcesIterator", "as", "$", "source", ")", "{", "// Processing all resources associated to the current source object", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "try", "{", "$", "this", "->", "processResourcesBySource", "(", "$", "source", ")", ";", "}", "catch", "(", "Exception", "\\", "PostParseException", "$", "e", ")", "{", "array_push", "(", "$", "errors", ",", "$", "e", ")", ";", "}", "catch", "(", "Exception", "\\", "ResourceProxyExceptionInterface", "$", "e", ")", "{", "$", "msg", "=", "sprintf", "(", "'General proxy error caught for the following source: \\'%s\\'. Error is: \\'%s\\'.'", ",", "$", "source", "->", "getName", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "errors", ",", "$", "msg", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "msg", "=", "sprintf", "(", "'General error caught for the following source: \\'%s\\'. Error is: \\'%s\\'.'", ",", "$", "source", "->", "getName", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "errors", ",", "$", "msg", ")", ";", "}", "}", "}", "// If errors, we throw a global process exception", "if", "(", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "throw", "new", "Exception", "\\", "GlobalProcessException", "(", "$", "errors", ",", "sprintf", "(", "'Errors while processing the sources for the following proxy: \\'%s\\'.'", ",", "$", "this", "->", "getProxyName", "(", ")", ")", ")", ";", "}", "}" ]
Processes all resources associated to the configured source objects for a proxy implementation @throws \Msl\ResourceProxy\Exception\GlobalProcessException @return void
[ "Processes", "all", "resources", "associated", "to", "the", "configured", "source", "objects", "for", "a", "proxy", "implementation" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L222-L261
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.processResourcesBySource
public function processResourcesBySource(SourceInterface $source) { // Getting all resources for the given source and process them (save the content in the configured output folder) // Getting result iterator $resources = $this->getResources($source); // Parsing the resource iterator $globalSuccess = true; $postParseErrors = array(); foreach ($resources as $resourceKey => $resource) { if ($resource instanceof ResourceInterface) { // Moving the content of the current resource to the output folder $success = $resource->moveToOutputFolder($this->outputFolder); if (!$success) { $globalSuccess = false; } try { // Launching the post parse unit action for the current resource object $result = $source->postParseUnitAction($resourceKey, $success); if ($result instanceof ParseResult && $result->getResult() === false) { $sourcePostParseError = sprintf( 'Post parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } catch (\Exception $e) { $sourcePostParseError = sprintf( 'Exception has been caught while parsing the resources for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } } try { // Running the global post parse action for the current source object $result = $source->postParseGlobalAction($globalSuccess); if ($result instanceof ParseResult && $result->getResult() === false) { $globalSourcePostParseError = sprintf( 'Post global parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } } catch (\Exception $e) { $globalSourcePostParseError = sprintf( 'Exception has been caught while running the post global action for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } // Launch a unique exception with all the post parse unit and post global errors if (count($postParseErrors) > 0) { throw new Exception\PostParseException( $postParseErrors, sprintf( 'Errors while running post unit and global actions for the following source: \'%s\'.', $source->toString() ) ); } // Return true if no exception return true; }
php
public function processResourcesBySource(SourceInterface $source) { // Getting all resources for the given source and process them (save the content in the configured output folder) // Getting result iterator $resources = $this->getResources($source); // Parsing the resource iterator $globalSuccess = true; $postParseErrors = array(); foreach ($resources as $resourceKey => $resource) { if ($resource instanceof ResourceInterface) { // Moving the content of the current resource to the output folder $success = $resource->moveToOutputFolder($this->outputFolder); if (!$success) { $globalSuccess = false; } try { // Launching the post parse unit action for the current resource object $result = $source->postParseUnitAction($resourceKey, $success); if ($result instanceof ParseResult && $result->getResult() === false) { $sourcePostParseError = sprintf( 'Post parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } catch (\Exception $e) { $sourcePostParseError = sprintf( 'Exception has been caught while parsing the resources for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } } try { // Running the global post parse action for the current source object $result = $source->postParseGlobalAction($globalSuccess); if ($result instanceof ParseResult && $result->getResult() === false) { $globalSourcePostParseError = sprintf( 'Post global parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } } catch (\Exception $e) { $globalSourcePostParseError = sprintf( 'Exception has been caught while running the post global action for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } // Launch a unique exception with all the post parse unit and post global errors if (count($postParseErrors) > 0) { throw new Exception\PostParseException( $postParseErrors, sprintf( 'Errors while running post unit and global actions for the following source: \'%s\'.', $source->toString() ) ); } // Return true if no exception return true; }
[ "public", "function", "processResourcesBySource", "(", "SourceInterface", "$", "source", ")", "{", "// Getting all resources for the given source and process them (save the content in the configured output folder)", "// Getting result iterator", "$", "resources", "=", "$", "this", "->", "getResources", "(", "$", "source", ")", ";", "// Parsing the resource iterator", "$", "globalSuccess", "=", "true", ";", "$", "postParseErrors", "=", "array", "(", ")", ";", "foreach", "(", "$", "resources", "as", "$", "resourceKey", "=>", "$", "resource", ")", "{", "if", "(", "$", "resource", "instanceof", "ResourceInterface", ")", "{", "// Moving the content of the current resource to the output folder", "$", "success", "=", "$", "resource", "->", "moveToOutputFolder", "(", "$", "this", "->", "outputFolder", ")", ";", "if", "(", "!", "$", "success", ")", "{", "$", "globalSuccess", "=", "false", ";", "}", "try", "{", "// Launching the post parse unit action for the current resource object", "$", "result", "=", "$", "source", "->", "postParseUnitAction", "(", "$", "resourceKey", ",", "$", "success", ")", ";", "if", "(", "$", "result", "instanceof", "ParseResult", "&&", "$", "result", "->", "getResult", "(", ")", "===", "false", ")", "{", "$", "sourcePostParseError", "=", "sprintf", "(", "'Post parse error for source \\'%s\\'. Error message is: \\'%s\\'.'", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "result", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "sourcePostParseError", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "sourcePostParseError", "=", "sprintf", "(", "'Exception has been caught while parsing the resources for the source object \\'%s\\'. Error is: \\'%s\\''", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "sourcePostParseError", ")", ";", "}", "}", "}", "try", "{", "// Running the global post parse action for the current source object", "$", "result", "=", "$", "source", "->", "postParseGlobalAction", "(", "$", "globalSuccess", ")", ";", "if", "(", "$", "result", "instanceof", "ParseResult", "&&", "$", "result", "->", "getResult", "(", ")", "===", "false", ")", "{", "$", "globalSourcePostParseError", "=", "sprintf", "(", "'Post global parse error for source \\'%s\\'. Error message is: \\'%s\\'.'", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "result", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "globalSourcePostParseError", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "globalSourcePostParseError", "=", "sprintf", "(", "'Exception has been caught while running the post global action for the source object \\'%s\\'. Error is: \\'%s\\''", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "globalSourcePostParseError", ")", ";", "}", "// Launch a unique exception with all the post parse unit and post global errors", "if", "(", "count", "(", "$", "postParseErrors", ")", ">", "0", ")", "{", "throw", "new", "Exception", "\\", "PostParseException", "(", "$", "postParseErrors", ",", "sprintf", "(", "'Errors while running post unit and global actions for the following source: \\'%s\\'.'", ",", "$", "source", "->", "toString", "(", ")", ")", ")", ";", "}", "// Return true if no exception", "return", "true", ";", "}" ]
Processes all resources associated to the given Source object @param SourceInterface $source the source object to be processed @throws \Msl\ResourceProxy\Exception\SourceGetDataException @throws \Msl\ResourceProxy\Exception\PostParseException @return bool
[ "Processes", "all", "resources", "associated", "to", "the", "given", "Source", "object" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L273-L344
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.processResourcesBySourceName
public function processResourcesBySourceName($sourceName) { // Getting source object $source = $this->getSourceByName($sourceName); if (!$source instanceof SourceInterface) { throw new Exception\SourceNotFoundException( $sourceName, sprintf( 'Impossible to find a source object with the following name: \'%s\'.', $sourceName ) ); } // Now processing the found source object return $this->processResourcesBySource($source); }
php
public function processResourcesBySourceName($sourceName) { // Getting source object $source = $this->getSourceByName($sourceName); if (!$source instanceof SourceInterface) { throw new Exception\SourceNotFoundException( $sourceName, sprintf( 'Impossible to find a source object with the following name: \'%s\'.', $sourceName ) ); } // Now processing the found source object return $this->processResourcesBySource($source); }
[ "public", "function", "processResourcesBySourceName", "(", "$", "sourceName", ")", "{", "// Getting source object", "$", "source", "=", "$", "this", "->", "getSourceByName", "(", "$", "sourceName", ")", ";", "if", "(", "!", "$", "source", "instanceof", "SourceInterface", ")", "{", "throw", "new", "Exception", "\\", "SourceNotFoundException", "(", "$", "sourceName", ",", "sprintf", "(", "'Impossible to find a source object with the following name: \\'%s\\'.'", ",", "$", "sourceName", ")", ")", ";", "}", "// Now processing the found source object", "return", "$", "this", "->", "processResourcesBySource", "(", "$", "source", ")", ";", "}" ]
Processes all resources associated to a Source object for the given source name @param string $sourceName the source name to be processed @return bool @throws \Msl\ResourceProxy\Exception\SourceNotFoundException @throws \Msl\ResourceProxy\Exception\SourceGetDataException @throws \Msl\ResourceProxy\Exception\PostParseException
[ "Processes", "all", "resources", "associated", "to", "a", "Source", "object", "for", "the", "given", "source", "name" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L357-L373
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getCurrentResources
public function getCurrentResources() { // Getting the current Source element $source = $this->getCurrentSource(); // Getting the data if ($source instanceof SourceInterface) { // Getting result iterator return $this->getResources($source); } return null; }
php
public function getCurrentResources() { // Getting the current Source element $source = $this->getCurrentSource(); // Getting the data if ($source instanceof SourceInterface) { // Getting result iterator return $this->getResources($source); } return null; }
[ "public", "function", "getCurrentResources", "(", ")", "{", "// Getting the current Source element", "$", "source", "=", "$", "this", "->", "getCurrentSource", "(", ")", ";", "// Getting the data", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "// Getting result iterator", "return", "$", "this", "->", "getResources", "(", "$", "source", ")", ";", "}", "return", "null", ";", "}" ]
Returns an Iterator instance containing all the resources for the current source object (from the source iterator). @throws \Msl\ResourceProxy\Exception\SourceGetDataException @return null|Iterator
[ "Returns", "an", "Iterator", "instance", "containing", "all", "the", "resources", "for", "the", "current", "source", "object", "(", "from", "the", "source", "iterator", ")", "." ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L385-L396
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getSourceByName
public function getSourceByName($sourceName) { if (isset($this->sources[$sourceName])) { return $this->sources[$sourceName]; } return null; }
php
public function getSourceByName($sourceName) { if (isset($this->sources[$sourceName])) { return $this->sources[$sourceName]; } return null; }
[ "public", "function", "getSourceByName", "(", "$", "sourceName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "sources", "[", "$", "sourceName", "]", ")", ")", "{", "return", "$", "this", "->", "sources", "[", "$", "sourceName", "]", ";", "}", "return", "null", ";", "}" ]
Returns the Source object for the given source name @param string $sourceName the source name @return null|SourceInterface
[ "Returns", "the", "Source", "object", "for", "the", "given", "source", "name" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L439-L445
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getResources
public function getResources(SourceInterface $source) { // Getting resources iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the resources for the following source object: %s', $source->toString() ) ); } }
php
public function getResources(SourceInterface $source) { // Getting resources iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the resources for the following source object: %s', $source->toString() ) ); } }
[ "public", "function", "getResources", "(", "SourceInterface", "$", "source", ")", "{", "// Getting resources iterator", "try", "{", "return", "$", "source", "->", "getContentIterator", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "SourceGetDataException", "(", "sprintf", "(", "'Exception caught while getting the resources for the following source object: %s'", ",", "$", "source", "->", "toString", "(", ")", ")", ")", ";", "}", "}" ]
Returns an Iterator containing all the resources for the given source object @param \Msl\ResourceProxy\Source\SourceInterface $source the source object @throws \Msl\ResourceProxy\Exception\SourceGetDataException @return null|Iterator
[ "Returns", "an", "Iterator", "containing", "all", "the", "resources", "for", "the", "given", "source", "object" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L456-L469
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getResourcesBySourceName
public function getResourcesBySourceName($sourceName) { // Getting source object first $source = $this->getSourceByName($sourceName); // Getting the data if ($source instanceof SourceInterface) { // Getting result iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the content for the following source object: %s', $source->toString() ) ); } } return null; }
php
public function getResourcesBySourceName($sourceName) { // Getting source object first $source = $this->getSourceByName($sourceName); // Getting the data if ($source instanceof SourceInterface) { // Getting result iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the content for the following source object: %s', $source->toString() ) ); } } return null; }
[ "public", "function", "getResourcesBySourceName", "(", "$", "sourceName", ")", "{", "// Getting source object first", "$", "source", "=", "$", "this", "->", "getSourceByName", "(", "$", "sourceName", ")", ";", "// Getting the data", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "// Getting result iterator", "try", "{", "return", "$", "source", "->", "getContentIterator", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "SourceGetDataException", "(", "sprintf", "(", "'Exception caught while getting the content for the following source object: %s'", ",", "$", "source", "->", "toString", "(", ")", ")", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns an Iterator containing all the resources for the given source name @param string $sourceName the source name @throws \Msl\ResourceProxy\Exception\SourceGetDataException @return null|Iterator
[ "Returns", "an", "Iterator", "containing", "all", "the", "resources", "for", "the", "given", "source", "name" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L480-L500
jasny/codeception-module
src/Module.php
Module.initContainer
protected function initContainer() { $container = $this->loadContainer(Configuration::projectDir() . $this->config['container']); if (!$container instanceof ContainerInterface) { throw new \UnexpectedValueException("Failed to get a container from '{$this->config['container']}'"); } return $container; }
php
protected function initContainer() { $container = $this->loadContainer(Configuration::projectDir() . $this->config['container']); if (!$container instanceof ContainerInterface) { throw new \UnexpectedValueException("Failed to get a container from '{$this->config['container']}'"); } return $container; }
[ "protected", "function", "initContainer", "(", ")", "{", "$", "container", "=", "$", "this", "->", "loadContainer", "(", "Configuration", "::", "projectDir", "(", ")", ".", "$", "this", "->", "config", "[", "'container'", "]", ")", ";", "if", "(", "!", "$", "container", "instanceof", "ContainerInterface", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Failed to get a container from '{$this->config['container']}'\"", ")", ";", "}", "return", "$", "container", ";", "}" ]
Get the container. @return ContainerInterface
[ "Get", "the", "container", "." ]
train
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L61-L70
jasny/codeception-module
src/Module.php
Module.init
public function init() { $this->container = $this->initContainer(); if ($this->container->has(ServerRequestInterface::class)) { $this->baseRequest = $this->container->get(ServerRequestInterface::class); } if ($this->container->has(ResponseInterface::class)) { $this->baseResponse = $this->container->get(ResponseInterface::class); } }
php
public function init() { $this->container = $this->initContainer(); if ($this->container->has(ServerRequestInterface::class)) { $this->baseRequest = $this->container->get(ServerRequestInterface::class); } if ($this->container->has(ResponseInterface::class)) { $this->baseResponse = $this->container->get(ResponseInterface::class); } }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "container", "=", "$", "this", "->", "initContainer", "(", ")", ";", "if", "(", "$", "this", "->", "container", "->", "has", "(", "ServerRequestInterface", "::", "class", ")", ")", "{", "$", "this", "->", "baseRequest", "=", "$", "this", "->", "container", "->", "get", "(", "ServerRequestInterface", "::", "class", ")", ";", "}", "if", "(", "$", "this", "->", "container", "->", "has", "(", "ResponseInterface", "::", "class", ")", ")", "{", "$", "this", "->", "baseResponse", "=", "$", "this", "->", "container", "->", "get", "(", "ResponseInterface", "::", "class", ")", ";", "}", "}" ]
Initialize the module
[ "Initialize", "the", "module" ]
train
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L109-L120
jasny/codeception-module
src/Module.php
Module._before
public function _before(TestInterface $test) { $this->init(); $this->client = new Connector(); $this->client->setRouter($this->container->get(RouterInterface::class)); if (isset($this->baseRequest)) { $this->client->setBaseRequest($this->baseRequest); } if (isset($this->baseResponse)) { $this->client->setBaseResponse($this->baseResponse); } parent::_before($test); }
php
public function _before(TestInterface $test) { $this->init(); $this->client = new Connector(); $this->client->setRouter($this->container->get(RouterInterface::class)); if (isset($this->baseRequest)) { $this->client->setBaseRequest($this->baseRequest); } if (isset($this->baseResponse)) { $this->client->setBaseResponse($this->baseResponse); } parent::_before($test); }
[ "public", "function", "_before", "(", "TestInterface", "$", "test", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "this", "->", "client", "=", "new", "Connector", "(", ")", ";", "$", "this", "->", "client", "->", "setRouter", "(", "$", "this", "->", "container", "->", "get", "(", "RouterInterface", "::", "class", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "baseRequest", ")", ")", "{", "$", "this", "->", "client", "->", "setBaseRequest", "(", "$", "this", "->", "baseRequest", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "baseResponse", ")", ")", "{", "$", "this", "->", "client", "->", "setBaseResponse", "(", "$", "this", "->", "baseResponse", ")", ";", "}", "parent", "::", "_before", "(", "$", "test", ")", ";", "}" ]
Before each test @param TestInterface $test
[ "Before", "each", "test" ]
train
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L153-L169
jasny/codeception-module
src/Module.php
Module._after
public function _after(TestInterface $test) { if ($this->sessionStatus() === PHP_SESSION_ACTIVE) { $this->sessionDestroy(); } if (isset($this->client) && $this->client instanceof Connector) { $this->client->reset(); if (isset($this->baseRequest)) { $this->baseRequest = $this->client->getBaseRequest(); } if (isset($this->baseResponse)) { $this->baseResponse = $this->client->getBaseResponse(); } } parent::_after($test); }
php
public function _after(TestInterface $test) { if ($this->sessionStatus() === PHP_SESSION_ACTIVE) { $this->sessionDestroy(); } if (isset($this->client) && $this->client instanceof Connector) { $this->client->reset(); if (isset($this->baseRequest)) { $this->baseRequest = $this->client->getBaseRequest(); } if (isset($this->baseResponse)) { $this->baseResponse = $this->client->getBaseResponse(); } } parent::_after($test); }
[ "public", "function", "_after", "(", "TestInterface", "$", "test", ")", "{", "if", "(", "$", "this", "->", "sessionStatus", "(", ")", "===", "PHP_SESSION_ACTIVE", ")", "{", "$", "this", "->", "sessionDestroy", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "client", ")", "&&", "$", "this", "->", "client", "instanceof", "Connector", ")", "{", "$", "this", "->", "client", "->", "reset", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "baseRequest", ")", ")", "{", "$", "this", "->", "baseRequest", "=", "$", "this", "->", "client", "->", "getBaseRequest", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "baseResponse", ")", ")", "{", "$", "this", "->", "baseResponse", "=", "$", "this", "->", "client", "->", "getBaseResponse", "(", ")", ";", "}", "}", "parent", "::", "_after", "(", "$", "test", ")", ";", "}" ]
After each test @param TestInterface $test
[ "After", "each", "test" ]
train
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L176-L195
jasny/codeception-module
src/Module.php
Module._failed
public function _failed(TestInterface $test, $fail) { if (isset($this->container) && $this->container->has(ErrorHandlerInterface::class)) { $error = $this->container->get(ErrorHandlerInterface::class)->getError(); if ($error) { $this->debug((string)$error); } } parent::_failed($test, $fail); }
php
public function _failed(TestInterface $test, $fail) { if (isset($this->container) && $this->container->has(ErrorHandlerInterface::class)) { $error = $this->container->get(ErrorHandlerInterface::class)->getError(); if ($error) { $this->debug((string)$error); } } parent::_failed($test, $fail); }
[ "public", "function", "_failed", "(", "TestInterface", "$", "test", ",", "$", "fail", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "container", ")", "&&", "$", "this", "->", "container", "->", "has", "(", "ErrorHandlerInterface", "::", "class", ")", ")", "{", "$", "error", "=", "$", "this", "->", "container", "->", "get", "(", "ErrorHandlerInterface", "::", "class", ")", "->", "getError", "(", ")", ";", "if", "(", "$", "error", ")", "{", "$", "this", "->", "debug", "(", "(", "string", ")", "$", "error", ")", ";", "}", "}", "parent", "::", "_failed", "(", "$", "test", ",", "$", "fail", ")", ";", "}" ]
Called when test fails @param TestInterface $test @param mixed $fail
[ "Called", "when", "test", "fails" ]
train
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L203-L215
kbond/ControllerUtil
src/EventListener/SerializerViewListener.php
SerializerViewListener.getContent
protected function getContent(View $view, $format) { return $this->serializer->serialize($view->getData(), $format); }
php
protected function getContent(View $view, $format) { return $this->serializer->serialize($view->getData(), $format); }
[ "protected", "function", "getContent", "(", "View", "$", "view", ",", "$", "format", ")", "{", "return", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "view", "->", "getData", "(", ")", ",", "$", "format", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/kbond/ControllerUtil/blob/67375d43c73d6a3f16356f3d683f62b176766e91/src/EventListener/SerializerViewListener.php#L39-L42
wboyz/laravel-enum
src/BaseEnum.php
BaseEnum.getValue
public static function getValue($key) { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); if (! $reflectionClass->hasConstant($key)) { return static::DEFAULT_VALUE; } return $reflectionClass->getConstant($key); }
php
public static function getValue($key) { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); if (! $reflectionClass->hasConstant($key)) { return static::DEFAULT_VALUE; } return $reflectionClass->getConstant($key); }
[ "public", "static", "function", "getValue", "(", "$", "key", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "!", "$", "reflectionClass", "->", "hasConstant", "(", "$", "key", ")", ")", "{", "return", "static", "::", "DEFAULT_VALUE", ";", "}", "return", "$", "reflectionClass", "->", "getConstant", "(", "$", "key", ")", ";", "}" ]
Returns an enum value by its key. @return mixed
[ "Returns", "an", "enum", "value", "by", "its", "key", "." ]
train
https://github.com/wboyz/laravel-enum/blob/7e34d4eca779e3764fb9b56f612db9bc0b54c9c2/src/BaseEnum.php#L16-L26
wboyz/laravel-enum
src/BaseEnum.php
BaseEnum.toDictionary
public static function toDictionary() { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); $dictionary = $reflectionClass->getConstants(); unset($dictionary['DEFAULT_VALUE']); return $dictionary; }
php
public static function toDictionary() { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); $dictionary = $reflectionClass->getConstants(); unset($dictionary['DEFAULT_VALUE']); return $dictionary; }
[ "public", "static", "function", "toDictionary", "(", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "$", "dictionary", "=", "$", "reflectionClass", "->", "getConstants", "(", ")", ";", "unset", "(", "$", "dictionary", "[", "'DEFAULT_VALUE'", "]", ")", ";", "return", "$", "dictionary", ";", "}" ]
Returns the enum as dictionary. @return array
[ "Returns", "the", "enum", "as", "dictionary", "." ]
train
https://github.com/wboyz/laravel-enum/blob/7e34d4eca779e3764fb9b56f612db9bc0b54c9c2/src/BaseEnum.php#L53-L62
windwork/wf-db
lib/adapter/MySQLi.php
MySQLi.getAll
public function getAll($sql, array $args = []) { $result = $this->query($sql, $args); if (!$result) { return []; } $rows = $result->fetch_all(MYSQLI_ASSOC); return $rows; }
php
public function getAll($sql, array $args = []) { $result = $this->query($sql, $args); if (!$result) { return []; } $rows = $result->fetch_all(MYSQLI_ASSOC); return $rows; }
[ "public", "function", "getAll", "(", "$", "sql", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "result", "=", "$", "this", "->", "query", "(", "$", "sql", ",", "$", "args", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "[", "]", ";", "}", "$", "rows", "=", "$", "result", "->", "fetch_all", "(", "MYSQLI_ASSOC", ")", ";", "return", "$", "rows", ";", "}" ]
(non-PHPdoc) @see DB::getAll()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/adapter/MySQLi.php#L139-L150
windwork/wf-db
lib/adapter/MySQLi.php
MySQLi.getRow
public function getRow($sql, array $args = []) { $result = $this->query($sql, $args); if (!$result) { return []; } $row = $result->fetch_row(); return $row; }
php
public function getRow($sql, array $args = []) { $result = $this->query($sql, $args); if (!$result) { return []; } $row = $result->fetch_row(); return $row; }
[ "public", "function", "getRow", "(", "$", "sql", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "result", "=", "$", "this", "->", "query", "(", "$", "sql", ",", "$", "args", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "[", "]", ";", "}", "$", "row", "=", "$", "result", "->", "fetch_row", "(", ")", ";", "return", "$", "row", ";", "}" ]
(non-PHPdoc) @see DB::getRow()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/adapter/MySQLi.php#L156-L167
windwork/wf-db
lib/adapter/MySQLi.php
MySQLi.getColumn
public function getColumn($sql, array $args = []) { $result = $this->query($sql, $args); if (!$result) { return null; } $row = $result->fetch_row(); return $row[0]; }
php
public function getColumn($sql, array $args = []) { $result = $this->query($sql, $args); if (!$result) { return null; } $row = $result->fetch_row(); return $row[0]; }
[ "public", "function", "getColumn", "(", "$", "sql", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "result", "=", "$", "this", "->", "query", "(", "$", "sql", ",", "$", "args", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "null", ";", "}", "$", "row", "=", "$", "result", "->", "fetch_row", "(", ")", ";", "return", "$", "row", "[", "0", "]", ";", "}" ]
(non-PHPdoc) @see DB::getColumn()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/adapter/MySQLi.php#L173-L184
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.send
public function send( ezcMail $mail ) { // sanity check the e-mail // need at least one recepient if ( ( count( $mail->to ) + count( $mail->cc ) + count( $mail->bcc ) ) < 1 ) { throw new ezcMailTransportException( "Can not send e-mail with no 'to' recipients." ); } try { // open connection unless we are connected already. if ( $this->status != self::STATUS_AUTHENTICATED ) { $this->connect(); } if ( isset( $mail->returnPath ) ) { $this->cmdMail( $mail->returnPath->email ); } else { $this->cmdMail( $mail->from->email ); } // each recepient must be listed here. // this controls where the mail is actually sent as SMTP does not // read the headers itself foreach ( $mail->to as $address ) { $this->cmdRcpt( $address->email ); } foreach ( $mail->cc as $address ) { $this->cmdRcpt( $address->email ); } foreach ( $mail->bcc as $address ) { $this->cmdRcpt( $address->email ); } // done with the from and recipients, lets send the mail itself $this->cmdData(); // A '.' on a line ends the mail. Make sure this does not happen in // the data we want to send. also called transparancy in the RFC, // section 4.5.2 $data = $mail->generate(); $data = str_replace( self::CRLF . '.', self::CRLF . '..', $data ); if ( $data[0] == '.' ) { $data = '.' . $data; } $this->sendData( $data ); $this->sendData( '.' ); if ( $this->getReplyCode( $error ) !== '250' ) { throw new ezcMailTransportSmtpException( "Error: {$error}" ); } } catch ( ezcMailTransportSmtpException $e ) { throw new ezcMailTransportException( $e->getMessage() ); // TODO: reset connection here.pin } // close connection unless we should keep it if ( $this->keepConnection === false ) { try { $this->disconnect(); } catch ( Exception $e ) { // Eat! We don't care anyway since we are aborting the connection } } }
php
public function send( ezcMail $mail ) { // sanity check the e-mail // need at least one recepient if ( ( count( $mail->to ) + count( $mail->cc ) + count( $mail->bcc ) ) < 1 ) { throw new ezcMailTransportException( "Can not send e-mail with no 'to' recipients." ); } try { // open connection unless we are connected already. if ( $this->status != self::STATUS_AUTHENTICATED ) { $this->connect(); } if ( isset( $mail->returnPath ) ) { $this->cmdMail( $mail->returnPath->email ); } else { $this->cmdMail( $mail->from->email ); } // each recepient must be listed here. // this controls where the mail is actually sent as SMTP does not // read the headers itself foreach ( $mail->to as $address ) { $this->cmdRcpt( $address->email ); } foreach ( $mail->cc as $address ) { $this->cmdRcpt( $address->email ); } foreach ( $mail->bcc as $address ) { $this->cmdRcpt( $address->email ); } // done with the from and recipients, lets send the mail itself $this->cmdData(); // A '.' on a line ends the mail. Make sure this does not happen in // the data we want to send. also called transparancy in the RFC, // section 4.5.2 $data = $mail->generate(); $data = str_replace( self::CRLF . '.', self::CRLF . '..', $data ); if ( $data[0] == '.' ) { $data = '.' . $data; } $this->sendData( $data ); $this->sendData( '.' ); if ( $this->getReplyCode( $error ) !== '250' ) { throw new ezcMailTransportSmtpException( "Error: {$error}" ); } } catch ( ezcMailTransportSmtpException $e ) { throw new ezcMailTransportException( $e->getMessage() ); // TODO: reset connection here.pin } // close connection unless we should keep it if ( $this->keepConnection === false ) { try { $this->disconnect(); } catch ( Exception $e ) { // Eat! We don't care anyway since we are aborting the connection } } }
[ "public", "function", "send", "(", "ezcMail", "$", "mail", ")", "{", "// sanity check the e-mail", "// need at least one recepient", "if", "(", "(", "count", "(", "$", "mail", "->", "to", ")", "+", "count", "(", "$", "mail", "->", "cc", ")", "+", "count", "(", "$", "mail", "->", "bcc", ")", ")", "<", "1", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can not send e-mail with no 'to' recipients.\"", ")", ";", "}", "try", "{", "// open connection unless we are connected already.", "if", "(", "$", "this", "->", "status", "!=", "self", "::", "STATUS_AUTHENTICATED", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "mail", "->", "returnPath", ")", ")", "{", "$", "this", "->", "cmdMail", "(", "$", "mail", "->", "returnPath", "->", "email", ")", ";", "}", "else", "{", "$", "this", "->", "cmdMail", "(", "$", "mail", "->", "from", "->", "email", ")", ";", "}", "// each recepient must be listed here.", "// this controls where the mail is actually sent as SMTP does not", "// read the headers itself", "foreach", "(", "$", "mail", "->", "to", "as", "$", "address", ")", "{", "$", "this", "->", "cmdRcpt", "(", "$", "address", "->", "email", ")", ";", "}", "foreach", "(", "$", "mail", "->", "cc", "as", "$", "address", ")", "{", "$", "this", "->", "cmdRcpt", "(", "$", "address", "->", "email", ")", ";", "}", "foreach", "(", "$", "mail", "->", "bcc", "as", "$", "address", ")", "{", "$", "this", "->", "cmdRcpt", "(", "$", "address", "->", "email", ")", ";", "}", "// done with the from and recipients, lets send the mail itself", "$", "this", "->", "cmdData", "(", ")", ";", "// A '.' on a line ends the mail. Make sure this does not happen in", "// the data we want to send. also called transparancy in the RFC,", "// section 4.5.2", "$", "data", "=", "$", "mail", "->", "generate", "(", ")", ";", "$", "data", "=", "str_replace", "(", "self", "::", "CRLF", ".", "'.'", ",", "self", "::", "CRLF", ".", "'..'", ",", "$", "data", ")", ";", "if", "(", "$", "data", "[", "0", "]", "==", "'.'", ")", "{", "$", "data", "=", "'.'", ".", "$", "data", ";", "}", "$", "this", "->", "sendData", "(", "$", "data", ")", ";", "$", "this", "->", "sendData", "(", "'.'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'250'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"Error: {$error}\"", ")", ";", "}", "}", "catch", "(", "ezcMailTransportSmtpException", "$", "e", ")", "{", "throw", "new", "ezcMailTransportException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "// TODO: reset connection here.pin", "}", "// close connection unless we should keep it", "if", "(", "$", "this", "->", "keepConnection", "===", "false", ")", "{", "try", "{", "$", "this", "->", "disconnect", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// Eat! We don't care anyway since we are aborting the connection", "}", "}", "}" ]
Sends the ezcMail $mail using the SMTP protocol. If you want to send several emails use keepConnection() to leave the connection to the server open between each mail. @throws ezcMailTransportException if the mail could not be sent @throws ezcBaseFeatureNotFoundException if trying to use SSL and the openssl extension is not installed @param ezcMail $mail
[ "Sends", "the", "ezcMail", "$mail", "using", "the", "SMTP", "protocol", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L443-L523
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.connect
protected function connect() { $errno = null; $errstr = null; if ( $this->options->connectionType !== self::CONNECTION_PLAIN && !ezcBaseFeatures::hasExtensionSupport( 'openssl' ) ) { throw new ezcBaseExtensionNotFoundException( 'openssl', null, "PHP not configured --with-openssl." ); } if ( count( $this->options->connectionOptions ) > 0 ) { $context = stream_context_create( $this->options->connectionOptions ); $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout, STREAM_CLIENT_CONNECT, $context ); } else { $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout ); } if ( is_resource( $this->connection ) ) { stream_set_timeout( $this->connection, $this->options->timeout ); $this->status = self::STATUS_CONNECTED; $greeting = $this->getData(); $this->login(); } else { throw new ezcMailTransportSmtpException( "Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}." ); } }
php
protected function connect() { $errno = null; $errstr = null; if ( $this->options->connectionType !== self::CONNECTION_PLAIN && !ezcBaseFeatures::hasExtensionSupport( 'openssl' ) ) { throw new ezcBaseExtensionNotFoundException( 'openssl', null, "PHP not configured --with-openssl." ); } if ( count( $this->options->connectionOptions ) > 0 ) { $context = stream_context_create( $this->options->connectionOptions ); $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout, STREAM_CLIENT_CONNECT, $context ); } else { $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout ); } if ( is_resource( $this->connection ) ) { stream_set_timeout( $this->connection, $this->options->timeout ); $this->status = self::STATUS_CONNECTED; $greeting = $this->getData(); $this->login(); } else { throw new ezcMailTransportSmtpException( "Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}." ); } }
[ "protected", "function", "connect", "(", ")", "{", "$", "errno", "=", "null", ";", "$", "errstr", "=", "null", ";", "if", "(", "$", "this", "->", "options", "->", "connectionType", "!==", "self", "::", "CONNECTION_PLAIN", "&&", "!", "ezcBaseFeatures", "::", "hasExtensionSupport", "(", "'openssl'", ")", ")", "{", "throw", "new", "ezcBaseExtensionNotFoundException", "(", "'openssl'", ",", "null", ",", "\"PHP not configured --with-openssl.\"", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "options", "->", "connectionOptions", ")", ">", "0", ")", "{", "$", "context", "=", "stream_context_create", "(", "$", "this", "->", "options", "->", "connectionOptions", ")", ";", "$", "this", "->", "connection", "=", "@", "stream_socket_client", "(", "\"{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}\"", ",", "$", "errno", ",", "$", "errstr", ",", "$", "this", "->", "options", "->", "timeout", ",", "STREAM_CLIENT_CONNECT", ",", "$", "context", ")", ";", "}", "else", "{", "$", "this", "->", "connection", "=", "@", "stream_socket_client", "(", "\"{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}\"", ",", "$", "errno", ",", "$", "errstr", ",", "$", "this", "->", "options", "->", "timeout", ")", ";", "}", "if", "(", "is_resource", "(", "$", "this", "->", "connection", ")", ")", "{", "stream_set_timeout", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "options", "->", "timeout", ")", ";", "$", "this", "->", "status", "=", "self", "::", "STATUS_CONNECTED", ";", "$", "greeting", "=", "$", "this", "->", "getData", "(", ")", ";", "$", "this", "->", "login", "(", ")", ";", "}", "else", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}.\"", ")", ";", "}", "}" ]
Creates a connection to the SMTP server and initiates the login procedure. @todo The @ should be removed when PHP doesn't throw warnings for connect problems @throws ezcMailTransportSmtpException if no connection could be made or if the login failed @throws ezcBaseExtensionNotFoundException if trying to use SSL and the openssl extension is not installed
[ "Creates", "a", "connection", "to", "the", "SMTP", "server", "and", "initiates", "the", "login", "procedure", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L537-L569
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.login
protected function login() { if ( $this->doAuthenticate ) { $this->sendData( 'EHLO ' . $this->senderHost ); } else { $this->sendData( 'HELO ' . $this->senderHost ); } if ( $this->getReplyCode( $response ) !== '250' ) { throw new ezcMailTransportSmtpException( "HELO/EHLO failed with error: {$response}." ); } // do authentication if ( $this->doAuthenticate ) { if ( $this->options->preferredAuthMethod !== self::AUTH_AUTO ) { $this->auth( $this->options->preferredAuthMethod ); } else { preg_match( "/250-AUTH[= ](.*)/", $response, $matches ); if ( count( $matches ) > 0 ) { $methods = explode( ' ', trim( $matches[1] ) ); } if ( count( $matches ) === 0 || count( $methods ) === 0 ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept the AUTH command.' ); } $authenticated = false; $methods = $this->sortAuthMethods( $methods ); foreach ( $methods as $method ) { if ( $this->auth( $method ) === true ) { $authenticated = true; break; } } if ( $authenticated === false ) { throw new ezcMailTransportSmtpException( 'SMTP server did not respond correctly to any of the authentication methods ' . implode( ', ', $methods ) . '.' ); } } } $this->status = self::STATUS_AUTHENTICATED; }
php
protected function login() { if ( $this->doAuthenticate ) { $this->sendData( 'EHLO ' . $this->senderHost ); } else { $this->sendData( 'HELO ' . $this->senderHost ); } if ( $this->getReplyCode( $response ) !== '250' ) { throw new ezcMailTransportSmtpException( "HELO/EHLO failed with error: {$response}." ); } // do authentication if ( $this->doAuthenticate ) { if ( $this->options->preferredAuthMethod !== self::AUTH_AUTO ) { $this->auth( $this->options->preferredAuthMethod ); } else { preg_match( "/250-AUTH[= ](.*)/", $response, $matches ); if ( count( $matches ) > 0 ) { $methods = explode( ' ', trim( $matches[1] ) ); } if ( count( $matches ) === 0 || count( $methods ) === 0 ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept the AUTH command.' ); } $authenticated = false; $methods = $this->sortAuthMethods( $methods ); foreach ( $methods as $method ) { if ( $this->auth( $method ) === true ) { $authenticated = true; break; } } if ( $authenticated === false ) { throw new ezcMailTransportSmtpException( 'SMTP server did not respond correctly to any of the authentication methods ' . implode( ', ', $methods ) . '.' ); } } } $this->status = self::STATUS_AUTHENTICATED; }
[ "protected", "function", "login", "(", ")", "{", "if", "(", "$", "this", "->", "doAuthenticate", ")", "{", "$", "this", "->", "sendData", "(", "'EHLO '", ".", "$", "this", "->", "senderHost", ")", ";", "}", "else", "{", "$", "this", "->", "sendData", "(", "'HELO '", ".", "$", "this", "->", "senderHost", ")", ";", "}", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "response", ")", "!==", "'250'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"HELO/EHLO failed with error: {$response}.\"", ")", ";", "}", "// do authentication", "if", "(", "$", "this", "->", "doAuthenticate", ")", "{", "if", "(", "$", "this", "->", "options", "->", "preferredAuthMethod", "!==", "self", "::", "AUTH_AUTO", ")", "{", "$", "this", "->", "auth", "(", "$", "this", "->", "options", "->", "preferredAuthMethod", ")", ";", "}", "else", "{", "preg_match", "(", "\"/250-AUTH[= ](.*)/\"", ",", "$", "response", ",", "$", "matches", ")", ";", "if", "(", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "$", "methods", "=", "explode", "(", "' '", ",", "trim", "(", "$", "matches", "[", "1", "]", ")", ")", ";", "}", "if", "(", "count", "(", "$", "matches", ")", "===", "0", "||", "count", "(", "$", "methods", ")", "===", "0", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept the AUTH command.'", ")", ";", "}", "$", "authenticated", "=", "false", ";", "$", "methods", "=", "$", "this", "->", "sortAuthMethods", "(", "$", "methods", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "$", "this", "->", "auth", "(", "$", "method", ")", "===", "true", ")", "{", "$", "authenticated", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "authenticated", "===", "false", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not respond correctly to any of the authentication methods '", ".", "implode", "(", "', '", ",", "$", "methods", ")", ".", "'.'", ")", ";", "}", "}", "}", "$", "this", "->", "status", "=", "self", "::", "STATUS_AUTHENTICATED", ";", "}" ]
Performs the initial handshake with the SMTP server and authenticates the user, if login data is provided to the constructor. @throws ezcMailTransportSmtpException if the HELO/EHLO command or authentication fails
[ "Performs", "the", "initial", "handshake", "with", "the", "SMTP", "server", "and", "authenticates", "the", "user", "if", "login", "data", "is", "provided", "to", "the", "constructor", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L579-L632
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.getSupportedAuthMethods
public static function getSupportedAuthMethods() { return array( ezcMailSmtpTransport::AUTH_DIGEST_MD5, ezcMailSmtpTransport::AUTH_CRAM_MD5, ezcMailSmtpTransport::AUTH_NTLM, ezcMailSmtpTransport::AUTH_LOGIN, ezcMailSmtpTransport::AUTH_PLAIN, ); }
php
public static function getSupportedAuthMethods() { return array( ezcMailSmtpTransport::AUTH_DIGEST_MD5, ezcMailSmtpTransport::AUTH_CRAM_MD5, ezcMailSmtpTransport::AUTH_NTLM, ezcMailSmtpTransport::AUTH_LOGIN, ezcMailSmtpTransport::AUTH_PLAIN, ); }
[ "public", "static", "function", "getSupportedAuthMethods", "(", ")", "{", "return", "array", "(", "ezcMailSmtpTransport", "::", "AUTH_DIGEST_MD5", ",", "ezcMailSmtpTransport", "::", "AUTH_CRAM_MD5", ",", "ezcMailSmtpTransport", "::", "AUTH_NTLM", ",", "ezcMailSmtpTransport", "::", "AUTH_LOGIN", ",", "ezcMailSmtpTransport", "::", "AUTH_PLAIN", ",", ")", ";", "}" ]
Returns an array with the authentication methods supported by the SMTP transport class (not by the SMTP server!). The returned array has the methods sorted by their relative strengths, so stronger methods are first in the array. @return array(string)
[ "Returns", "an", "array", "with", "the", "authentication", "methods", "supported", "by", "the", "SMTP", "transport", "class", "(", "not", "by", "the", "SMTP", "server!", ")", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L643-L652
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.sortAuthMethods
protected function sortAuthMethods( array $methods ) { $result = array(); $unsupported = array(); $supportedAuthMethods = self::getSupportedAuthMethods(); foreach ( $supportedAuthMethods as $method ) { if ( in_array( $method, $methods ) ) { $result[] = $method; } } return $result; }
php
protected function sortAuthMethods( array $methods ) { $result = array(); $unsupported = array(); $supportedAuthMethods = self::getSupportedAuthMethods(); foreach ( $supportedAuthMethods as $method ) { if ( in_array( $method, $methods ) ) { $result[] = $method; } } return $result; }
[ "protected", "function", "sortAuthMethods", "(", "array", "$", "methods", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "unsupported", "=", "array", "(", ")", ";", "$", "supportedAuthMethods", "=", "self", "::", "getSupportedAuthMethods", "(", ")", ";", "foreach", "(", "$", "supportedAuthMethods", "as", "$", "method", ")", "{", "if", "(", "in_array", "(", "$", "method", ",", "$", "methods", ")", ")", "{", "$", "result", "[", "]", "=", "$", "method", ";", "}", "}", "return", "$", "result", ";", "}" ]
Sorts the specified array of AUTH methods $methods by strength, so higher strength methods will be used first. For example, if the server supports: <code> $methods = array( 'PLAIN', 'LOGIN', 'CRAM-MD5' ); </code> then this method will return: <code> $methods = array( 'CRAM-MD5', 'LOGIN', 'PLAIN' ); </code> @param array(string) $methods @return array(string)
[ "Sorts", "the", "specified", "array", "of", "AUTH", "methods", "$methods", "by", "strength", "so", "higher", "strength", "methods", "will", "be", "used", "first", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L671-L684
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.auth
protected function auth( $method ) { switch ( $method ) { case self::AUTH_DIGEST_MD5: $authenticated = $this->authDigestMd5(); break; case self::AUTH_CRAM_MD5: $authenticated = $this->authCramMd5(); break; case self::AUTH_NTLM: $authenticated = $this->authNtlm(); break; case self::AUTH_LOGIN: $authenticated = $this->authLogin(); break; case self::AUTH_PLAIN: $authenticated = $this->authPlain(); break; default: throw new ezcMailTransportSmtpException( "Unsupported AUTH method '{$method}'." ); } return $authenticated; }
php
protected function auth( $method ) { switch ( $method ) { case self::AUTH_DIGEST_MD5: $authenticated = $this->authDigestMd5(); break; case self::AUTH_CRAM_MD5: $authenticated = $this->authCramMd5(); break; case self::AUTH_NTLM: $authenticated = $this->authNtlm(); break; case self::AUTH_LOGIN: $authenticated = $this->authLogin(); break; case self::AUTH_PLAIN: $authenticated = $this->authPlain(); break; default: throw new ezcMailTransportSmtpException( "Unsupported AUTH method '{$method}'." ); } return $authenticated; }
[ "protected", "function", "auth", "(", "$", "method", ")", "{", "switch", "(", "$", "method", ")", "{", "case", "self", "::", "AUTH_DIGEST_MD5", ":", "$", "authenticated", "=", "$", "this", "->", "authDigestMd5", "(", ")", ";", "break", ";", "case", "self", "::", "AUTH_CRAM_MD5", ":", "$", "authenticated", "=", "$", "this", "->", "authCramMd5", "(", ")", ";", "break", ";", "case", "self", "::", "AUTH_NTLM", ":", "$", "authenticated", "=", "$", "this", "->", "authNtlm", "(", ")", ";", "break", ";", "case", "self", "::", "AUTH_LOGIN", ":", "$", "authenticated", "=", "$", "this", "->", "authLogin", "(", ")", ";", "break", ";", "case", "self", "::", "AUTH_PLAIN", ":", "$", "authenticated", "=", "$", "this", "->", "authPlain", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "ezcMailTransportSmtpException", "(", "\"Unsupported AUTH method '{$method}'.\"", ")", ";", "}", "return", "$", "authenticated", ";", "}" ]
Calls the appropiate authentication method based on $method. @throws ezcMailTransportSmtpException if $method is not supported by the transport class @return bool
[ "Calls", "the", "appropiate", "authentication", "method", "based", "on", "$method", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L693-L722
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authDigestMd5
protected function authDigestMd5() { $this->sendData( 'AUTH DIGEST-MD5' ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH DIGEST-MD5.' ); } $serverDigest = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = explode( ',', $serverDigest ); foreach ( $parts as $part ) { $args = explode( '=', $part, 2 ); $params[trim( $args[0] )] = trim( $args[1] ); } if ( !isset( $params['nonce'] ) || !isset( $params['algorithm'] ) ) { throw new ezcMailTransportSmtpException( 'SMTP server did not send a correct DIGEST-MD5 challenge.' ); } $nonce = trim( $params['nonce'], '"' ); $algorithm = trim( $params['algorithm'], '"' ); $qop = 'auth'; $realm = isset( $params['realm'] ) ? trim( $params['realm'], '"' ) : $this->serverHost; $cnonce = $this->generateNonce( 32 ); $digestUri = "smtp/{$this->serverHost}"; $nc = '00000001'; $charset = isset( $params['charset'] ) ? trim( $params['charset'], '"' ) : 'utf-8'; $maxbuf = isset( $params['maxbuf'] ) ? trim( $params['maxbuf'], '"' ) : 65536; $response = ''; $A2 = "AUTHENTICATE:{$digestUri}"; $A1 = pack( 'H32', md5( "{$this->user}:{$realm}:{$this->password}" ) ) . ":{$nonce}:{$cnonce}"; $response = md5( md5( $A1 ) . ":{$nonce}:{$nc}:{$cnonce}:{$qop}:" . md5( $A2 ) ); $loginParams = array( 'username' => "\"{$this->user}\"", 'cnonce' => "\"{$cnonce}\"", 'nonce' => "\"{$nonce}\"", 'nc' => $nc, 'qop' => $qop, 'digest-uri' => "\"{$digestUri}\"", 'charset' => $charset, 'realm' => "\"{$realm}\"", 'response' => $response, 'maxbuf' => $maxbuf ); $parts = array(); foreach ( $loginParams as $key => $value ) { $parts[] = "{$key}={$value}"; } $login = base64_encode( implode( ',', $parts ) ); $this->sendData( $login ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } $serverResponse = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = explode( '=', $serverResponse ); $rspauthServer = trim( $parts[1] ); $A2 = ":{$digestUri}"; $rspauthClient = md5( md5( $A1 ) . ":{$nonce}:{$nc}:{$cnonce}:{$qop}:" . md5( $A2 ) ); if ( $rspauthServer !== $rspauthClient ) { throw new ezcMailTransportSmtpException( 'SMTP server did not responded correctly to the DIGEST-MD5 authentication.' ); } $this->sendData( '' ); if ( $this->getReplyCode( $serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not allow DIGEST-MD5 authentication.' ); } return true; }
php
protected function authDigestMd5() { $this->sendData( 'AUTH DIGEST-MD5' ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH DIGEST-MD5.' ); } $serverDigest = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = explode( ',', $serverDigest ); foreach ( $parts as $part ) { $args = explode( '=', $part, 2 ); $params[trim( $args[0] )] = trim( $args[1] ); } if ( !isset( $params['nonce'] ) || !isset( $params['algorithm'] ) ) { throw new ezcMailTransportSmtpException( 'SMTP server did not send a correct DIGEST-MD5 challenge.' ); } $nonce = trim( $params['nonce'], '"' ); $algorithm = trim( $params['algorithm'], '"' ); $qop = 'auth'; $realm = isset( $params['realm'] ) ? trim( $params['realm'], '"' ) : $this->serverHost; $cnonce = $this->generateNonce( 32 ); $digestUri = "smtp/{$this->serverHost}"; $nc = '00000001'; $charset = isset( $params['charset'] ) ? trim( $params['charset'], '"' ) : 'utf-8'; $maxbuf = isset( $params['maxbuf'] ) ? trim( $params['maxbuf'], '"' ) : 65536; $response = ''; $A2 = "AUTHENTICATE:{$digestUri}"; $A1 = pack( 'H32', md5( "{$this->user}:{$realm}:{$this->password}" ) ) . ":{$nonce}:{$cnonce}"; $response = md5( md5( $A1 ) . ":{$nonce}:{$nc}:{$cnonce}:{$qop}:" . md5( $A2 ) ); $loginParams = array( 'username' => "\"{$this->user}\"", 'cnonce' => "\"{$cnonce}\"", 'nonce' => "\"{$nonce}\"", 'nc' => $nc, 'qop' => $qop, 'digest-uri' => "\"{$digestUri}\"", 'charset' => $charset, 'realm' => "\"{$realm}\"", 'response' => $response, 'maxbuf' => $maxbuf ); $parts = array(); foreach ( $loginParams as $key => $value ) { $parts[] = "{$key}={$value}"; } $login = base64_encode( implode( ',', $parts ) ); $this->sendData( $login ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } $serverResponse = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = explode( '=', $serverResponse ); $rspauthServer = trim( $parts[1] ); $A2 = ":{$digestUri}"; $rspauthClient = md5( md5( $A1 ) . ":{$nonce}:{$nc}:{$cnonce}:{$qop}:" . md5( $A2 ) ); if ( $rspauthServer !== $rspauthClient ) { throw new ezcMailTransportSmtpException( 'SMTP server did not responded correctly to the DIGEST-MD5 authentication.' ); } $this->sendData( '' ); if ( $this->getReplyCode( $serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not allow DIGEST-MD5 authentication.' ); } return true; }
[ "protected", "function", "authDigestMd5", "(", ")", "{", "$", "this", "->", "sendData", "(", "'AUTH DIGEST-MD5'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH DIGEST-MD5.'", ")", ";", "}", "$", "serverDigest", "=", "base64_decode", "(", "trim", "(", "substr", "(", "$", "serverResponse", ",", "4", ")", ")", ")", ";", "$", "parts", "=", "explode", "(", "','", ",", "$", "serverDigest", ")", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "args", "=", "explode", "(", "'='", ",", "$", "part", ",", "2", ")", ";", "$", "params", "[", "trim", "(", "$", "args", "[", "0", "]", ")", "]", "=", "trim", "(", "$", "args", "[", "1", "]", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'nonce'", "]", ")", "||", "!", "isset", "(", "$", "params", "[", "'algorithm'", "]", ")", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not send a correct DIGEST-MD5 challenge.'", ")", ";", "}", "$", "nonce", "=", "trim", "(", "$", "params", "[", "'nonce'", "]", ",", "'\"'", ")", ";", "$", "algorithm", "=", "trim", "(", "$", "params", "[", "'algorithm'", "]", ",", "'\"'", ")", ";", "$", "qop", "=", "'auth'", ";", "$", "realm", "=", "isset", "(", "$", "params", "[", "'realm'", "]", ")", "?", "trim", "(", "$", "params", "[", "'realm'", "]", ",", "'\"'", ")", ":", "$", "this", "->", "serverHost", ";", "$", "cnonce", "=", "$", "this", "->", "generateNonce", "(", "32", ")", ";", "$", "digestUri", "=", "\"smtp/{$this->serverHost}\"", ";", "$", "nc", "=", "'00000001'", ";", "$", "charset", "=", "isset", "(", "$", "params", "[", "'charset'", "]", ")", "?", "trim", "(", "$", "params", "[", "'charset'", "]", ",", "'\"'", ")", ":", "'utf-8'", ";", "$", "maxbuf", "=", "isset", "(", "$", "params", "[", "'maxbuf'", "]", ")", "?", "trim", "(", "$", "params", "[", "'maxbuf'", "]", ",", "'\"'", ")", ":", "65536", ";", "$", "response", "=", "''", ";", "$", "A2", "=", "\"AUTHENTICATE:{$digestUri}\"", ";", "$", "A1", "=", "pack", "(", "'H32'", ",", "md5", "(", "\"{$this->user}:{$realm}:{$this->password}\"", ")", ")", ".", "\":{$nonce}:{$cnonce}\"", ";", "$", "response", "=", "md5", "(", "md5", "(", "$", "A1", ")", ".", "\":{$nonce}:{$nc}:{$cnonce}:{$qop}:\"", ".", "md5", "(", "$", "A2", ")", ")", ";", "$", "loginParams", "=", "array", "(", "'username'", "=>", "\"\\\"{$this->user}\\\"\"", ",", "'cnonce'", "=>", "\"\\\"{$cnonce}\\\"\"", ",", "'nonce'", "=>", "\"\\\"{$nonce}\\\"\"", ",", "'nc'", "=>", "$", "nc", ",", "'qop'", "=>", "$", "qop", ",", "'digest-uri'", "=>", "\"\\\"{$digestUri}\\\"\"", ",", "'charset'", "=>", "$", "charset", ",", "'realm'", "=>", "\"\\\"{$realm}\\\"\"", ",", "'response'", "=>", "$", "response", ",", "'maxbuf'", "=>", "$", "maxbuf", ")", ";", "$", "parts", "=", "array", "(", ")", ";", "foreach", "(", "$", "loginParams", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "parts", "[", "]", "=", "\"{$key}={$value}\"", ";", "}", "$", "login", "=", "base64_encode", "(", "implode", "(", "','", ",", "$", "parts", ")", ")", ";", "$", "this", "->", "sendData", "(", "$", "login", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "$", "serverResponse", "=", "base64_decode", "(", "trim", "(", "substr", "(", "$", "serverResponse", ",", "4", ")", ")", ")", ";", "$", "parts", "=", "explode", "(", "'='", ",", "$", "serverResponse", ")", ";", "$", "rspauthServer", "=", "trim", "(", "$", "parts", "[", "1", "]", ")", ";", "$", "A2", "=", "\":{$digestUri}\"", ";", "$", "rspauthClient", "=", "md5", "(", "md5", "(", "$", "A1", ")", ".", "\":{$nonce}:{$nc}:{$cnonce}:{$qop}:\"", ".", "md5", "(", "$", "A2", ")", ")", ";", "if", "(", "$", "rspauthServer", "!==", "$", "rspauthClient", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not responded correctly to the DIGEST-MD5 authentication.'", ")", ";", "}", "$", "this", "->", "sendData", "(", "''", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not allow DIGEST-MD5 authentication.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH DIGEST-MD5' and returns true if successful. @todo implement auth-int and auth-conf quality of protection (qop) modes @todo support other algorithms than md5-sess? @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "DIGEST", "-", "MD5", "and", "returns", "true", "if", "successful", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L735-L818
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authCramMd5
protected function authCramMd5() { $this->sendData( 'AUTH CRAM-MD5' ); if ( $this->getReplyCode( $response ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH CRAM-MD5.' ); } $serverDigest = trim( substr( $response, 4 ) ); $clientDigest = hash_hmac( 'md5', base64_decode( $serverDigest ), $this->password ); $login = base64_encode( "{$this->user} {$clientDigest}" ); $this->sendData( $login ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
php
protected function authCramMd5() { $this->sendData( 'AUTH CRAM-MD5' ); if ( $this->getReplyCode( $response ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH CRAM-MD5.' ); } $serverDigest = trim( substr( $response, 4 ) ); $clientDigest = hash_hmac( 'md5', base64_decode( $serverDigest ), $this->password ); $login = base64_encode( "{$this->user} {$clientDigest}" ); $this->sendData( $login ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
[ "protected", "function", "authCramMd5", "(", ")", "{", "$", "this", "->", "sendData", "(", "'AUTH CRAM-MD5'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "response", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH CRAM-MD5.'", ")", ";", "}", "$", "serverDigest", "=", "trim", "(", "substr", "(", "$", "response", ",", "4", ")", ")", ";", "$", "clientDigest", "=", "hash_hmac", "(", "'md5'", ",", "base64_decode", "(", "$", "serverDigest", ")", ",", "$", "this", "->", "password", ")", ";", "$", "login", "=", "base64_encode", "(", "\"{$this->user} {$clientDigest}\"", ")", ";", "$", "this", "->", "sendData", "(", "$", "login", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH CRAM-MD5' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "CRAM", "-", "MD5", "and", "returns", "true", "if", "successful", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L828-L847
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlm
protected function authNtlm() { if ( !ezcBaseFeatures::hasExtensionSupport( 'mcrypt' ) ) { throw new ezcBaseExtensionNotFoundException( 'mcrypt', null, "PHP not compiled with --with-mcrypt." ); } // Send NTLM type 1 message $msg1 = base64_encode( $this->authNtlmMessageType1( $this->senderHost, $this->serverHost ) ); $this->sendData( "AUTH NTLM {$msg1}" ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH NTLM.' ); } // Parse NTLM type 2 message $msg2 = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = array( substr( $msg2, 0, 8 ), // Signature ("NTLMSSP\0") substr( $msg2, 8, 4 ), // Message type substr( $msg2, 12, 8 ), // Target name (security buffer) substr( $msg2, 20, 4 ), // Flags substr( $msg2, 24, 8 ), // Challenge substr( $msg2, 32 ) // The rest of information ); $challenge = $parts[4]; // Send NTLM type 3 message $msg3 = base64_encode( $this->authNtlmMessageType3( $challenge, $this->user, $this->password, $this->senderHost, $this->serverHost ) ); $this->sendData( $msg3 ); if ( $this->getReplyCode( $serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not allow NTLM authentication.' ); } }
php
protected function authNtlm() { if ( !ezcBaseFeatures::hasExtensionSupport( 'mcrypt' ) ) { throw new ezcBaseExtensionNotFoundException( 'mcrypt', null, "PHP not compiled with --with-mcrypt." ); } // Send NTLM type 1 message $msg1 = base64_encode( $this->authNtlmMessageType1( $this->senderHost, $this->serverHost ) ); $this->sendData( "AUTH NTLM {$msg1}" ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH NTLM.' ); } // Parse NTLM type 2 message $msg2 = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = array( substr( $msg2, 0, 8 ), // Signature ("NTLMSSP\0") substr( $msg2, 8, 4 ), // Message type substr( $msg2, 12, 8 ), // Target name (security buffer) substr( $msg2, 20, 4 ), // Flags substr( $msg2, 24, 8 ), // Challenge substr( $msg2, 32 ) // The rest of information ); $challenge = $parts[4]; // Send NTLM type 3 message $msg3 = base64_encode( $this->authNtlmMessageType3( $challenge, $this->user, $this->password, $this->senderHost, $this->serverHost ) ); $this->sendData( $msg3 ); if ( $this->getReplyCode( $serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not allow NTLM authentication.' ); } }
[ "protected", "function", "authNtlm", "(", ")", "{", "if", "(", "!", "ezcBaseFeatures", "::", "hasExtensionSupport", "(", "'mcrypt'", ")", ")", "{", "throw", "new", "ezcBaseExtensionNotFoundException", "(", "'mcrypt'", ",", "null", ",", "\"PHP not compiled with --with-mcrypt.\"", ")", ";", "}", "// Send NTLM type 1 message", "$", "msg1", "=", "base64_encode", "(", "$", "this", "->", "authNtlmMessageType1", "(", "$", "this", "->", "senderHost", ",", "$", "this", "->", "serverHost", ")", ")", ";", "$", "this", "->", "sendData", "(", "\"AUTH NTLM {$msg1}\"", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH NTLM.'", ")", ";", "}", "// Parse NTLM type 2 message", "$", "msg2", "=", "base64_decode", "(", "trim", "(", "substr", "(", "$", "serverResponse", ",", "4", ")", ")", ")", ";", "$", "parts", "=", "array", "(", "substr", "(", "$", "msg2", ",", "0", ",", "8", ")", ",", "// Signature (\"NTLMSSP\\0\")", "substr", "(", "$", "msg2", ",", "8", ",", "4", ")", ",", "// Message type", "substr", "(", "$", "msg2", ",", "12", ",", "8", ")", ",", "// Target name (security buffer)", "substr", "(", "$", "msg2", ",", "20", ",", "4", ")", ",", "// Flags", "substr", "(", "$", "msg2", ",", "24", ",", "8", ")", ",", "// Challenge", "substr", "(", "$", "msg2", ",", "32", ")", "// The rest of information", ")", ";", "$", "challenge", "=", "$", "parts", "[", "4", "]", ";", "// Send NTLM type 3 message", "$", "msg3", "=", "base64_encode", "(", "$", "this", "->", "authNtlmMessageType3", "(", "$", "challenge", ",", "$", "this", "->", "user", ",", "$", "this", "->", "password", ",", "$", "this", "->", "senderHost", ",", "$", "this", "->", "serverHost", ")", ")", ";", "$", "this", "->", "sendData", "(", "$", "msg3", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not allow NTLM authentication.'", ")", ";", "}", "}" ]
Tries to login to the SMTP server with 'AUTH NTLM' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "NTLM", "and", "returns", "true", "if", "successful", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L857-L894
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authLogin
protected function authLogin() { $this->sendData( 'AUTH LOGIN' ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH LOGIN.' ); } $this->sendData( base64_encode( $this->user ) ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( "SMTP server did not accept login: {$this->user}." ); } $this->sendData( base64_encode( $this->password ) ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
php
protected function authLogin() { $this->sendData( 'AUTH LOGIN' ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH LOGIN.' ); } $this->sendData( base64_encode( $this->user ) ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( "SMTP server did not accept login: {$this->user}." ); } $this->sendData( base64_encode( $this->password ) ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
[ "protected", "function", "authLogin", "(", ")", "{", "$", "this", "->", "sendData", "(", "'AUTH LOGIN'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH LOGIN.'", ")", ";", "}", "$", "this", "->", "sendData", "(", "base64_encode", "(", "$", "this", "->", "user", ")", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"SMTP server did not accept login: {$this->user}.\"", ")", ";", "}", "$", "this", "->", "sendData", "(", "base64_encode", "(", "$", "this", "->", "password", ")", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH LOGIN' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "LOGIN", "and", "returns", "true", "if", "successful", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L904-L925
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authPlain
protected function authPlain() { $digest = base64_encode( "\0{$this->user}\0{$this->password}" ); $this->sendData( "AUTH PLAIN {$digest}" ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
php
protected function authPlain() { $digest = base64_encode( "\0{$this->user}\0{$this->password}" ); $this->sendData( "AUTH PLAIN {$digest}" ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
[ "protected", "function", "authPlain", "(", ")", "{", "$", "digest", "=", "base64_encode", "(", "\"\\0{$this->user}\\0{$this->password}\"", ")", ";", "$", "this", "->", "sendData", "(", "\"AUTH PLAIN {$digest}\"", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH PLAIN' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "PLAIN", "and", "returns", "true", "if", "successful", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L935-L945
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.disconnect
public function disconnect() { if ( $this->status != self::STATUS_NOT_CONNECTED ) { $this->sendData( 'QUIT' ); $replyCode = $this->getReplyCode( $error ) !== '221'; fclose( $this->connection ); $this->status = self::STATUS_NOT_CONNECTED; if ( $replyCode ) { throw new ezcMailTransportSmtpException( "QUIT failed with error: $error." ); } } }
php
public function disconnect() { if ( $this->status != self::STATUS_NOT_CONNECTED ) { $this->sendData( 'QUIT' ); $replyCode = $this->getReplyCode( $error ) !== '221'; fclose( $this->connection ); $this->status = self::STATUS_NOT_CONNECTED; if ( $replyCode ) { throw new ezcMailTransportSmtpException( "QUIT failed with error: $error." ); } } }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "$", "this", "->", "status", "!=", "self", "::", "STATUS_NOT_CONNECTED", ")", "{", "$", "this", "->", "sendData", "(", "'QUIT'", ")", ";", "$", "replyCode", "=", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'221'", ";", "fclose", "(", "$", "this", "->", "connection", ")", ";", "$", "this", "->", "status", "=", "self", "::", "STATUS_NOT_CONNECTED", ";", "if", "(", "$", "replyCode", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"QUIT failed with error: $error.\"", ")", ";", "}", "}", "}" ]
Sends the QUIT command to the server and breaks the connection. @throws ezcMailTransportSmtpException if the QUIT command failed
[ "Sends", "the", "QUIT", "command", "to", "the", "server", "and", "breaks", "the", "connection", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L953-L966
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.cmdMail
protected function cmdMail( $from ) { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'MAIL FROM:' . $this->composeSmtpMailAddress( $from ) . '' ); if ( $this->getReplyCode( $error ) !== '250' ) { throw new ezcMailTransportSmtpException( "MAIL FROM failed with error: $error." ); } } }
php
protected function cmdMail( $from ) { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'MAIL FROM:' . $this->composeSmtpMailAddress( $from ) . '' ); if ( $this->getReplyCode( $error ) !== '250' ) { throw new ezcMailTransportSmtpException( "MAIL FROM failed with error: $error." ); } } }
[ "protected", "function", "cmdMail", "(", "$", "from", ")", "{", "if", "(", "$", "this", "->", "status", "===", "self", "::", "STATUS_AUTHENTICATED", ")", "{", "$", "this", "->", "sendData", "(", "'MAIL FROM:'", ".", "$", "this", "->", "composeSmtpMailAddress", "(", "$", "from", ")", ".", "''", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'250'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"MAIL FROM failed with error: $error.\"", ")", ";", "}", "}", "}" ]
Sends the MAIL FROM command, with the sender's mail address $from. This method must be called once to tell the server the sender address. The sender's mail address $from may be enclosed in angle brackets. @throws ezcMailTransportSmtpException if there is no valid connection or if the MAIL FROM command failed @param string $from
[ "Sends", "the", "MAIL", "FROM", "command", "with", "the", "sender", "s", "mail", "address", "$from", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L997-L1007
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.cmdRcpt
protected function cmdRcpt( $email ) { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'RCPT TO:' . $this->composeSmtpMailAddress( $email ) ); if ( $this->getReplyCode( $error ) !== '250' ) { throw new ezcMailTransportSmtpException( "RCPT TO failed with error: $error." ); } } }
php
protected function cmdRcpt( $email ) { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'RCPT TO:' . $this->composeSmtpMailAddress( $email ) ); if ( $this->getReplyCode( $error ) !== '250' ) { throw new ezcMailTransportSmtpException( "RCPT TO failed with error: $error." ); } } }
[ "protected", "function", "cmdRcpt", "(", "$", "email", ")", "{", "if", "(", "$", "this", "->", "status", "===", "self", "::", "STATUS_AUTHENTICATED", ")", "{", "$", "this", "->", "sendData", "(", "'RCPT TO:'", ".", "$", "this", "->", "composeSmtpMailAddress", "(", "$", "email", ")", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'250'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"RCPT TO failed with error: $error.\"", ")", ";", "}", "}", "}" ]
Sends the 'RCTP TO' to the server with the address $email. This method must be called once for each recipient of the mail including cc and bcc recipients. The RCPT TO commands control where the mail is actually sent. It does not affect the headers of the email. The recipient mail address $email may be enclosed in angle brackets. @throws ezcMailTransportSmtpException if there is no valid connection or if the RCPT TO command failed @param string $email
[ "Sends", "the", "RCTP", "TO", "to", "the", "server", "with", "the", "address", "$email", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1024-L1034
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.cmdData
protected function cmdData() { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'DATA' ); if ( $this->getReplyCode( $error ) !== '354' ) { throw new ezcMailTransportSmtpException( "DATA failed with error: $error." ); } } }
php
protected function cmdData() { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'DATA' ); if ( $this->getReplyCode( $error ) !== '354' ) { throw new ezcMailTransportSmtpException( "DATA failed with error: $error." ); } } }
[ "protected", "function", "cmdData", "(", ")", "{", "if", "(", "$", "this", "->", "status", "===", "self", "::", "STATUS_AUTHENTICATED", ")", "{", "$", "this", "->", "sendData", "(", "'DATA'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'354'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"DATA failed with error: $error.\"", ")", ";", "}", "}", "}" ]
Sends the DATA command to the SMTP server. @throws ezcMailTransportSmtpException if there is no valid connection or if the DATA command failed
[ "Sends", "the", "DATA", "command", "to", "the", "SMTP", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1043-L1053
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.getData
protected function getData() { $data = ''; $line = ''; $loops = 0; if ( is_resource( $this->connection ) ) { while ( ( strpos( $data, self::CRLF ) === false || (string) substr( $line, 3, 1 ) !== ' ' ) && $loops < 100 ) { $line = fgets( $this->connection, 512 ); $data .= $line; $loops++; } return $data; } throw new ezcMailTransportSmtpException( 'Could not read from SMTP stream. It was probably terminated by the host.' ); }
php
protected function getData() { $data = ''; $line = ''; $loops = 0; if ( is_resource( $this->connection ) ) { while ( ( strpos( $data, self::CRLF ) === false || (string) substr( $line, 3, 1 ) !== ' ' ) && $loops < 100 ) { $line = fgets( $this->connection, 512 ); $data .= $line; $loops++; } return $data; } throw new ezcMailTransportSmtpException( 'Could not read from SMTP stream. It was probably terminated by the host.' ); }
[ "protected", "function", "getData", "(", ")", "{", "$", "data", "=", "''", ";", "$", "line", "=", "''", ";", "$", "loops", "=", "0", ";", "if", "(", "is_resource", "(", "$", "this", "->", "connection", ")", ")", "{", "while", "(", "(", "strpos", "(", "$", "data", ",", "self", "::", "CRLF", ")", "===", "false", "||", "(", "string", ")", "substr", "(", "$", "line", ",", "3", ",", "1", ")", "!==", "' '", ")", "&&", "$", "loops", "<", "100", ")", "{", "$", "line", "=", "fgets", "(", "$", "this", "->", "connection", ",", "512", ")", ";", "$", "data", ".=", "$", "line", ";", "$", "loops", "++", ";", "}", "return", "$", "data", ";", "}", "throw", "new", "ezcMailTransportSmtpException", "(", "'Could not read from SMTP stream. It was probably terminated by the host.'", ")", ";", "}" ]
Returns data received from the connection stream. @throws ezcMailTransportSmtpException if there is no valid connection @return string
[ "Returns", "data", "received", "from", "the", "connection", "stream", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1083-L1100
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.generateNonce
protected function generateNonce( $length = 32 ) { $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $result = ''; for ( $i = 0; $i < $length; $i++ ) { $result .= $chars[mt_rand( 0, strlen( $chars ) - 1 )]; } return $result; }
php
protected function generateNonce( $length = 32 ) { $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $result = ''; for ( $i = 0; $i < $length; $i++ ) { $result .= $chars[mt_rand( 0, strlen( $chars ) - 1 )]; } return $result; }
[ "protected", "function", "generateNonce", "(", "$", "length", "=", "32", ")", "{", "$", "chars", "=", "\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"", ";", "$", "result", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "$", "result", ".=", "$", "chars", "[", "mt_rand", "(", "0", ",", "strlen", "(", "$", "chars", ")", "-", "1", ")", "]", ";", "}", "return", "$", "result", ";", "}" ]
Generates an alpha-numeric random string with the specified $length. Used in the DIGEST-MD5 authentication method. @param int $length @return string
[ "Generates", "an", "alpha", "-", "numeric", "random", "string", "with", "the", "specified", "$length", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1126-L1136
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmMessageType1
protected function authNtlmMessageType1( $workstation, $domain ) { $parts = array( "NTLMSSP\x00", "\x01\x00\x00\x00", "\x07\x32\x00\x00", $this->authNtlmSecurityBuffer( $domain, 32 + strlen( $workstation ) ), $this->authNtlmSecurityBuffer( $workstation, 32 ), $workstation, $domain ); return implode( "", $parts ); }
php
protected function authNtlmMessageType1( $workstation, $domain ) { $parts = array( "NTLMSSP\x00", "\x01\x00\x00\x00", "\x07\x32\x00\x00", $this->authNtlmSecurityBuffer( $domain, 32 + strlen( $workstation ) ), $this->authNtlmSecurityBuffer( $workstation, 32 ), $workstation, $domain ); return implode( "", $parts ); }
[ "protected", "function", "authNtlmMessageType1", "(", "$", "workstation", ",", "$", "domain", ")", "{", "$", "parts", "=", "array", "(", "\"NTLMSSP\\x00\"", ",", "\"\\x01\\x00\\x00\\x00\"", ",", "\"\\x07\\x32\\x00\\x00\"", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "domain", ",", "32", "+", "strlen", "(", "$", "workstation", ")", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "workstation", ",", "32", ")", ",", "$", "workstation", ",", "$", "domain", ")", ";", "return", "implode", "(", "\"\"", ",", "$", "parts", ")", ";", "}" ]
Generates an NTLM type 1 message. @param string $workstation @param string $domain @return string
[ "Generates", "an", "NTLM", "type", "1", "message", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1145-L1158
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmMessageType3
protected function authNtlmMessageType3( $challenge, $user, $password, $workstation, $domain ) { $domain = chunk_split( $domain, 1, "\x00" ); $user = chunk_split( $user, 1, "\x00" ); $workstation = chunk_split( $workstation, 1, "\x00" ); $lm = ''; $ntlm = $this->authNtlmResponse( $challenge, $password ); $session = ''; $domainOffset = 64; $userOffset = $domainOffset + strlen( $domain ); $workstationOffset = $userOffset + strlen( $user ); $lmOffset = $workstationOffset + strlen( $workstation ); $ntlmOffset = $lmOffset + strlen( $lm ); $sessionOffset = $ntlmOffset + strlen( $ntlm ); $parts = array( "NTLMSSP\x00", "\x03\x00\x00\x00", $this->authNtlmSecurityBuffer( $lm, $lmOffset ), $this->authNtlmSecurityBuffer( $ntlm, $ntlmOffset ), $this->authNtlmSecurityBuffer( $domain, $domainOffset ), $this->authNtlmSecurityBuffer( $user, $userOffset ), $this->authNtlmSecurityBuffer( $workstation, $workstationOffset ), $this->authNtlmSecurityBuffer( $session, $sessionOffset ), "\x01\x02\x00\x00", $domain, $user, $workstation, $lm, $ntlm ); return implode( '', $parts ); }
php
protected function authNtlmMessageType3( $challenge, $user, $password, $workstation, $domain ) { $domain = chunk_split( $domain, 1, "\x00" ); $user = chunk_split( $user, 1, "\x00" ); $workstation = chunk_split( $workstation, 1, "\x00" ); $lm = ''; $ntlm = $this->authNtlmResponse( $challenge, $password ); $session = ''; $domainOffset = 64; $userOffset = $domainOffset + strlen( $domain ); $workstationOffset = $userOffset + strlen( $user ); $lmOffset = $workstationOffset + strlen( $workstation ); $ntlmOffset = $lmOffset + strlen( $lm ); $sessionOffset = $ntlmOffset + strlen( $ntlm ); $parts = array( "NTLMSSP\x00", "\x03\x00\x00\x00", $this->authNtlmSecurityBuffer( $lm, $lmOffset ), $this->authNtlmSecurityBuffer( $ntlm, $ntlmOffset ), $this->authNtlmSecurityBuffer( $domain, $domainOffset ), $this->authNtlmSecurityBuffer( $user, $userOffset ), $this->authNtlmSecurityBuffer( $workstation, $workstationOffset ), $this->authNtlmSecurityBuffer( $session, $sessionOffset ), "\x01\x02\x00\x00", $domain, $user, $workstation, $lm, $ntlm ); return implode( '', $parts ); }
[ "protected", "function", "authNtlmMessageType3", "(", "$", "challenge", ",", "$", "user", ",", "$", "password", ",", "$", "workstation", ",", "$", "domain", ")", "{", "$", "domain", "=", "chunk_split", "(", "$", "domain", ",", "1", ",", "\"\\x00\"", ")", ";", "$", "user", "=", "chunk_split", "(", "$", "user", ",", "1", ",", "\"\\x00\"", ")", ";", "$", "workstation", "=", "chunk_split", "(", "$", "workstation", ",", "1", ",", "\"\\x00\"", ")", ";", "$", "lm", "=", "''", ";", "$", "ntlm", "=", "$", "this", "->", "authNtlmResponse", "(", "$", "challenge", ",", "$", "password", ")", ";", "$", "session", "=", "''", ";", "$", "domainOffset", "=", "64", ";", "$", "userOffset", "=", "$", "domainOffset", "+", "strlen", "(", "$", "domain", ")", ";", "$", "workstationOffset", "=", "$", "userOffset", "+", "strlen", "(", "$", "user", ")", ";", "$", "lmOffset", "=", "$", "workstationOffset", "+", "strlen", "(", "$", "workstation", ")", ";", "$", "ntlmOffset", "=", "$", "lmOffset", "+", "strlen", "(", "$", "lm", ")", ";", "$", "sessionOffset", "=", "$", "ntlmOffset", "+", "strlen", "(", "$", "ntlm", ")", ";", "$", "parts", "=", "array", "(", "\"NTLMSSP\\x00\"", ",", "\"\\x03\\x00\\x00\\x00\"", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "lm", ",", "$", "lmOffset", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "ntlm", ",", "$", "ntlmOffset", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "domain", ",", "$", "domainOffset", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "user", ",", "$", "userOffset", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "workstation", ",", "$", "workstationOffset", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "session", ",", "$", "sessionOffset", ")", ",", "\"\\x01\\x02\\x00\\x00\"", ",", "$", "domain", ",", "$", "user", ",", "$", "workstation", ",", "$", "lm", ",", "$", "ntlm", ")", ";", "return", "implode", "(", "''", ",", "$", "parts", ")", ";", "}" ]
Generates an NTLM type 3 message from the $challenge sent by the SMTP server in an NTLM type 2 message. @param string $challenge @param string $user @param string $password @param string $workstation @param string $domain @return string
[ "Generates", "an", "NTLM", "type", "3", "message", "from", "the", "$challenge", "sent", "by", "the", "SMTP", "server", "in", "an", "NTLM", "type", "2", "message", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1171-L1205
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmResponse
protected function authNtlmResponse( $challenge, $password ) { $password = chunk_split( $password, 1, "\x00" ); $password = hash( 'md4', $password, true ); $password .= str_repeat( "\x00", 21 - strlen( $password ) ); $td = mcrypt_module_open( 'des', '', 'ecb', '' ); $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND ); $response = ''; for ( $i = 0; $i < 21; $i += 7 ) { $packed = ''; for ( $p = $i; $p < $i + 7; $p++ ) { $packed .= str_pad( decbin( ord( substr( $password, $p, 1 ) ) ), 8, '0', STR_PAD_LEFT ); } $key = ''; for ( $p = 0; $p < strlen( $packed ); $p += 7 ) { $s = substr( $packed, $p, 7 ); $b = $s . ( ( substr_count( $s, '1' ) % 2 ) ? '0' : '1' ); $key .= chr( bindec( $b ) ); } mcrypt_generic_init( $td, $key, $iv ); $response .= mcrypt_generic( $td, $challenge ); mcrypt_generic_deinit( $td ); } mcrypt_module_close( $td ); return $response; }
php
protected function authNtlmResponse( $challenge, $password ) { $password = chunk_split( $password, 1, "\x00" ); $password = hash( 'md4', $password, true ); $password .= str_repeat( "\x00", 21 - strlen( $password ) ); $td = mcrypt_module_open( 'des', '', 'ecb', '' ); $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND ); $response = ''; for ( $i = 0; $i < 21; $i += 7 ) { $packed = ''; for ( $p = $i; $p < $i + 7; $p++ ) { $packed .= str_pad( decbin( ord( substr( $password, $p, 1 ) ) ), 8, '0', STR_PAD_LEFT ); } $key = ''; for ( $p = 0; $p < strlen( $packed ); $p += 7 ) { $s = substr( $packed, $p, 7 ); $b = $s . ( ( substr_count( $s, '1' ) % 2 ) ? '0' : '1' ); $key .= chr( bindec( $b ) ); } mcrypt_generic_init( $td, $key, $iv ); $response .= mcrypt_generic( $td, $challenge ); mcrypt_generic_deinit( $td ); } mcrypt_module_close( $td ); return $response; }
[ "protected", "function", "authNtlmResponse", "(", "$", "challenge", ",", "$", "password", ")", "{", "$", "password", "=", "chunk_split", "(", "$", "password", ",", "1", ",", "\"\\x00\"", ")", ";", "$", "password", "=", "hash", "(", "'md4'", ",", "$", "password", ",", "true", ")", ";", "$", "password", ".=", "str_repeat", "(", "\"\\x00\"", ",", "21", "-", "strlen", "(", "$", "password", ")", ")", ";", "$", "td", "=", "mcrypt_module_open", "(", "'des'", ",", "''", ",", "'ecb'", ",", "''", ")", ";", "$", "iv", "=", "mcrypt_create_iv", "(", "mcrypt_enc_get_iv_size", "(", "$", "td", ")", ",", "MCRYPT_RAND", ")", ";", "$", "response", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "21", ";", "$", "i", "+=", "7", ")", "{", "$", "packed", "=", "''", ";", "for", "(", "$", "p", "=", "$", "i", ";", "$", "p", "<", "$", "i", "+", "7", ";", "$", "p", "++", ")", "{", "$", "packed", ".=", "str_pad", "(", "decbin", "(", "ord", "(", "substr", "(", "$", "password", ",", "$", "p", ",", "1", ")", ")", ")", ",", "8", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}", "$", "key", "=", "''", ";", "for", "(", "$", "p", "=", "0", ";", "$", "p", "<", "strlen", "(", "$", "packed", ")", ";", "$", "p", "+=", "7", ")", "{", "$", "s", "=", "substr", "(", "$", "packed", ",", "$", "p", ",", "7", ")", ";", "$", "b", "=", "$", "s", ".", "(", "(", "substr_count", "(", "$", "s", ",", "'1'", ")", "%", "2", ")", "?", "'0'", ":", "'1'", ")", ";", "$", "key", ".=", "chr", "(", "bindec", "(", "$", "b", ")", ")", ";", "}", "mcrypt_generic_init", "(", "$", "td", ",", "$", "key", ",", "$", "iv", ")", ";", "$", "response", ".=", "mcrypt_generic", "(", "$", "td", ",", "$", "challenge", ")", ";", "mcrypt_generic_deinit", "(", "$", "td", ")", ";", "}", "mcrypt_module_close", "(", "$", "td", ")", ";", "return", "$", "response", ";", "}" ]
Calculates an NTLM response to be used in the creation of the NTLM type 3 message. @param string $challenge @param string $password @return string
[ "Calculates", "an", "NTLM", "response", "to", "be", "used", "in", "the", "creation", "of", "the", "NTLM", "type", "3", "message", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1215-L1248
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmSecurityBuffer
protected function authNtlmSecurityBuffer( $text, $offset ) { return pack( 'v', strlen( $text ) ) . pack( 'v', strlen( $text ) ) . pack( 'V', $offset ); }
php
protected function authNtlmSecurityBuffer( $text, $offset ) { return pack( 'v', strlen( $text ) ) . pack( 'v', strlen( $text ) ) . pack( 'V', $offset ); }
[ "protected", "function", "authNtlmSecurityBuffer", "(", "$", "text", ",", "$", "offset", ")", "{", "return", "pack", "(", "'v'", ",", "strlen", "(", "$", "text", ")", ")", ".", "pack", "(", "'v'", ",", "strlen", "(", "$", "text", ")", ")", ".", "pack", "(", "'V'", ",", "$", "offset", ")", ";", "}" ]
Creates an NTLM security buffer information string. The structure of the security buffer is: - a short containing the length of the buffer content in bytes (may be zero). - a short containing the allocated space for the buffer in bytes (greater than or equal to the length; typically the same as the length). - a long containing the offset to the start of the buffer in bytes (from the beginning of the NTLM message). Example: - buffer content length: 1234 bytes (0xd204 in hexa) - allocated space: 1234 bytes( 0xd204 in hexa) - offset: 4321 bytes (0xe1100000 in hexa) then the security buffer would be 0xd204d204e1100000 (in hexa). @param string $text @param int $offset @return string
[ "Creates", "an", "NTLM", "security", "buffer", "information", "string", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1272-L1277
surebert/surebert-framework
src/sb/Excel/Reader/HTML.php
HTML.getCssStyle
public function getCssStyle($row, $col, $sheet=0) { $css = ""; $font = $this->font($row, $col, $sheet); if ($font != "") { $css .= "font-family:$font;"; } $align = $this->align($row, $col, $sheet); if ($align != "") { $css .= "text-align:$align;"; } $height = $this->height($row, $col, $sheet); if ($height != "") { $css .= "font-size:$height" . "pt;"; } $bgcolor = $this->bgColor($row, $col, $sheet); if ($bgcolor != "") { $bgcolor = $this->colors[$bgcolor]; $css .= "background-color:$bgcolor;"; } $color = $this->color($row, $col, $sheet); if ($color != "") { $css .= "color:$color;"; } $bold = $this->bold($row, $col, $sheet); if ($bold) { $css .= "font-weight:bold;"; } $italic = $this->italic($row, $col, $sheet); if ($italic) { $css .= "font-style:italic;"; } $underline = $this->underline($row, $col, $sheet); if ($underline) { $css .= "text-decoration:underline;"; } // Borders $bLeft = $this->borderLeft($row, $col, $sheet); $bRight = $this->borderRight($row, $col, $sheet); $bTop = $this->borderTop($row, $col, $sheet); $bBottom = $this->borderBottom($row, $col, $sheet); $bLeftCol = $this->borderLeftColor($row, $col, $sheet); $bRightCol = $this->borderRightColor($row, $col, $sheet); $bTopCol = $this->borderTopColor($row, $col, $sheet); $bBottomCol = $this->borderBottomColor($row, $col, $sheet); // Try to output the minimal required style if ($bLeft != "" && $bLeft == $bRight && $bRight == $bTop && $bTop == $bBottom) { $css .= "border:" . $this->lineStylesCss[$bLeft] . ";"; } else { if ($bLeft != "") { $css .= "border-left:" . $this->lineStylesCss[$bLeft] . ";"; } if ($bRight != "") { $css .= "border-right:" . $this->lineStylesCss[$bRight] . ";"; } if ($bTop != "") { $css .= "border-top:" . $this->lineStylesCss[$bTop] . ";"; } if ($bBottom != "") { $css .= "border-bottom:" . $this->lineStylesCss[$bBottom] . ";"; } } // Only output border colors if there is an actual border specified if ($bLeft != "" && $bLeftCol != "") { $css .= "border-left-color:" . $bLeftCol . ";"; } if ($bRight != "" && $bRightCol != "") { $css .= "border-right-color:" . $bRightCol . ";"; } if ($bTop != "" && $bTopCol != "") { $css .= "border-top-color:" . $bTopCol . ";"; } if ($bBottom != "" && $bBottomCol != "") { $css .= "border-bottom-color:" . $bBottomCol . ";"; } return $css; }
php
public function getCssStyle($row, $col, $sheet=0) { $css = ""; $font = $this->font($row, $col, $sheet); if ($font != "") { $css .= "font-family:$font;"; } $align = $this->align($row, $col, $sheet); if ($align != "") { $css .= "text-align:$align;"; } $height = $this->height($row, $col, $sheet); if ($height != "") { $css .= "font-size:$height" . "pt;"; } $bgcolor = $this->bgColor($row, $col, $sheet); if ($bgcolor != "") { $bgcolor = $this->colors[$bgcolor]; $css .= "background-color:$bgcolor;"; } $color = $this->color($row, $col, $sheet); if ($color != "") { $css .= "color:$color;"; } $bold = $this->bold($row, $col, $sheet); if ($bold) { $css .= "font-weight:bold;"; } $italic = $this->italic($row, $col, $sheet); if ($italic) { $css .= "font-style:italic;"; } $underline = $this->underline($row, $col, $sheet); if ($underline) { $css .= "text-decoration:underline;"; } // Borders $bLeft = $this->borderLeft($row, $col, $sheet); $bRight = $this->borderRight($row, $col, $sheet); $bTop = $this->borderTop($row, $col, $sheet); $bBottom = $this->borderBottom($row, $col, $sheet); $bLeftCol = $this->borderLeftColor($row, $col, $sheet); $bRightCol = $this->borderRightColor($row, $col, $sheet); $bTopCol = $this->borderTopColor($row, $col, $sheet); $bBottomCol = $this->borderBottomColor($row, $col, $sheet); // Try to output the minimal required style if ($bLeft != "" && $bLeft == $bRight && $bRight == $bTop && $bTop == $bBottom) { $css .= "border:" . $this->lineStylesCss[$bLeft] . ";"; } else { if ($bLeft != "") { $css .= "border-left:" . $this->lineStylesCss[$bLeft] . ";"; } if ($bRight != "") { $css .= "border-right:" . $this->lineStylesCss[$bRight] . ";"; } if ($bTop != "") { $css .= "border-top:" . $this->lineStylesCss[$bTop] . ";"; } if ($bBottom != "") { $css .= "border-bottom:" . $this->lineStylesCss[$bBottom] . ";"; } } // Only output border colors if there is an actual border specified if ($bLeft != "" && $bLeftCol != "") { $css .= "border-left-color:" . $bLeftCol . ";"; } if ($bRight != "" && $bRightCol != "") { $css .= "border-right-color:" . $bRightCol . ";"; } if ($bTop != "" && $bTopCol != "") { $css .= "border-top-color:" . $bTopCol . ";"; } if ($bBottom != "" && $bBottomCol != "") { $css .= "border-bottom-color:" . $bBottomCol . ";"; } return $css; }
[ "public", "function", "getCssStyle", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", "=", "0", ")", "{", "$", "css", "=", "\"\"", ";", "$", "font", "=", "$", "this", "->", "font", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "font", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"font-family:$font;\"", ";", "}", "$", "align", "=", "$", "this", "->", "align", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "align", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"text-align:$align;\"", ";", "}", "$", "height", "=", "$", "this", "->", "height", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "height", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"font-size:$height\"", ".", "\"pt;\"", ";", "}", "$", "bgcolor", "=", "$", "this", "->", "bgColor", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "bgcolor", "!=", "\"\"", ")", "{", "$", "bgcolor", "=", "$", "this", "->", "colors", "[", "$", "bgcolor", "]", ";", "$", "css", ".=", "\"background-color:$bgcolor;\"", ";", "}", "$", "color", "=", "$", "this", "->", "color", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "color", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"color:$color;\"", ";", "}", "$", "bold", "=", "$", "this", "->", "bold", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "bold", ")", "{", "$", "css", ".=", "\"font-weight:bold;\"", ";", "}", "$", "italic", "=", "$", "this", "->", "italic", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "italic", ")", "{", "$", "css", ".=", "\"font-style:italic;\"", ";", "}", "$", "underline", "=", "$", "this", "->", "underline", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "underline", ")", "{", "$", "css", ".=", "\"text-decoration:underline;\"", ";", "}", "// Borders", "$", "bLeft", "=", "$", "this", "->", "borderLeft", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bRight", "=", "$", "this", "->", "borderRight", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bTop", "=", "$", "this", "->", "borderTop", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bBottom", "=", "$", "this", "->", "borderBottom", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bLeftCol", "=", "$", "this", "->", "borderLeftColor", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bRightCol", "=", "$", "this", "->", "borderRightColor", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bTopCol", "=", "$", "this", "->", "borderTopColor", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "bBottomCol", "=", "$", "this", "->", "borderBottomColor", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "// Try to output the minimal required style", "if", "(", "$", "bLeft", "!=", "\"\"", "&&", "$", "bLeft", "==", "$", "bRight", "&&", "$", "bRight", "==", "$", "bTop", "&&", "$", "bTop", "==", "$", "bBottom", ")", "{", "$", "css", ".=", "\"border:\"", ".", "$", "this", "->", "lineStylesCss", "[", "$", "bLeft", "]", ".", "\";\"", ";", "}", "else", "{", "if", "(", "$", "bLeft", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-left:\"", ".", "$", "this", "->", "lineStylesCss", "[", "$", "bLeft", "]", ".", "\";\"", ";", "}", "if", "(", "$", "bRight", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-right:\"", ".", "$", "this", "->", "lineStylesCss", "[", "$", "bRight", "]", ".", "\";\"", ";", "}", "if", "(", "$", "bTop", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-top:\"", ".", "$", "this", "->", "lineStylesCss", "[", "$", "bTop", "]", ".", "\";\"", ";", "}", "if", "(", "$", "bBottom", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-bottom:\"", ".", "$", "this", "->", "lineStylesCss", "[", "$", "bBottom", "]", ".", "\";\"", ";", "}", "}", "// Only output border colors if there is an actual border specified", "if", "(", "$", "bLeft", "!=", "\"\"", "&&", "$", "bLeftCol", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-left-color:\"", ".", "$", "bLeftCol", ".", "\";\"", ";", "}", "if", "(", "$", "bRight", "!=", "\"\"", "&&", "$", "bRightCol", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-right-color:\"", ".", "$", "bRightCol", ".", "\";\"", ";", "}", "if", "(", "$", "bTop", "!=", "\"\"", "&&", "$", "bTopCol", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-top-color:\"", ".", "$", "bTopCol", ".", "\";\"", ";", "}", "if", "(", "$", "bBottom", "!=", "\"\"", "&&", "$", "bBottomCol", "!=", "\"\"", ")", "{", "$", "css", ".=", "\"border-bottom-color:\"", ".", "$", "bBottomCol", ".", "\";\"", ";", "}", "return", "$", "css", ";", "}" ]
Converts excel file cell style info into css @param int $row @param int $col @param int $sheet @return string
[ "Converts", "excel", "file", "cell", "style", "info", "into", "css" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader/HTML.php#L21-L98
surebert/surebert-framework
src/sb/Excel/Reader/HTML.php
HTML.hyperlink
public function hyperlink($row, $col, $sheet=0) { $link = isset($this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink']) ? $this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink'] : false; if ($link) { return $link['link']; } return ''; }
php
public function hyperlink($row, $col, $sheet=0) { $link = isset($this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink']) ? $this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink'] : false; if ($link) { return $link['link']; } return ''; }
[ "public", "function", "hyperlink", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", "=", "0", ")", "{", "$", "link", "=", "isset", "(", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "'hyperlink'", "]", ")", "?", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "'hyperlink'", "]", ":", "false", ";", "if", "(", "$", "link", ")", "{", "return", "$", "link", "[", "'link'", "]", ";", "}", "return", "''", ";", "}" ]
get hyperlink if cell is hyperlinked @param int $row @param int $col @param int $sheet @return string
[ "get", "hyperlink", "if", "cell", "is", "hyperlinked" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader/HTML.php#L107-L114
surebert/surebert-framework
src/sb/Excel/Reader/HTML.php
HTML.toHtml
public function toHtml($row_numbers=false, $col_letters=false, $sheet=0, $table_class='excel') { $out = "<table class=\"$table_class\" cellspacing=0>"; if ($col_letters) { $out .= "<thead>\n\t<tr>"; if ($row_numbers) { $out .= "\n\t\t<th>&nbsp</th>"; } for ($i = 1; $i <= $this->colcount($sheet); $i++) { $style = "width:" . ($this->colwidth($i, $sheet) * 1) . "px;"; if ($this->colhidden($i, $sheet)) { $style .= "display:none;"; } $out .= "\n\t\t<th style=\"$style\">" . strtoupper($this->colindexes[$i]) . "</th>"; } $out .= "</tr></thead>\n"; } $out .= "<tbody>\n"; $row_count = $this->rowcount($sheet); for ($row = 1; $row <= $this->rowcount($sheet); $row++) { $rowheight = $this->rowheight($row, $sheet); $style = "height:" . ($rowheight * (4 / 3)) . "px;"; if ($this->rowhidden($row, $sheet)) { $style .= "display:none;"; } $out .= "\n\t<tr style=\"$style\">"; if ($row_numbers) { $out .= "\n\t\t<th>$row</th>"; } $colcount = $this->colcount($sheet); for ($col = 1; $col <= $colcount; $col++) { // Account for Rowspans/Colspans $rowspan = $this->rowspan($row, $col, $sheet); $colspan = $this->colspan($row, $col, $sheet); for ($i = 0; $i < $rowspan; $i++) { for ($j = 0; $j < $colspan; $j++) { if ($i > 0 || $j > 0) { $this->sheets[$sheet]['cellsInfo'][$row + $i][$col + $j]['dontprint'] = 1; } } } if (!isset($this->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']) || !$this->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']) { $style = $this->getCssStyle($row, $col, $sheet); if ($this->colhidden($col, $sheet)) { $style .= "display:none;"; } $out .= "\n\t\t<td style=\"$style\"" . ($colspan > 1 ? " colspan=$colspan" : "") . ($rowspan > 1 ? " rowspan=$rowspan" : "") . ">"; $val = $this->val($row, $col, $sheet); if ($val == '') { $val = "&nbsp;"; } else { $val = htmlentities($val, ENT_NOQUOTES, 'utf-8'); $link = $this->hyperlink($row, $col, $sheet); if ($link != '') { $val = "<a href=\"$link\">$val</a>"; } } $out .= "<nobr>" . nl2br($val) . "</nobr>"; $out .= "</td>"; } } $out .= "</tr>\n"; } $out .= "</tbody></table>"; return $out; }
php
public function toHtml($row_numbers=false, $col_letters=false, $sheet=0, $table_class='excel') { $out = "<table class=\"$table_class\" cellspacing=0>"; if ($col_letters) { $out .= "<thead>\n\t<tr>"; if ($row_numbers) { $out .= "\n\t\t<th>&nbsp</th>"; } for ($i = 1; $i <= $this->colcount($sheet); $i++) { $style = "width:" . ($this->colwidth($i, $sheet) * 1) . "px;"; if ($this->colhidden($i, $sheet)) { $style .= "display:none;"; } $out .= "\n\t\t<th style=\"$style\">" . strtoupper($this->colindexes[$i]) . "</th>"; } $out .= "</tr></thead>\n"; } $out .= "<tbody>\n"; $row_count = $this->rowcount($sheet); for ($row = 1; $row <= $this->rowcount($sheet); $row++) { $rowheight = $this->rowheight($row, $sheet); $style = "height:" . ($rowheight * (4 / 3)) . "px;"; if ($this->rowhidden($row, $sheet)) { $style .= "display:none;"; } $out .= "\n\t<tr style=\"$style\">"; if ($row_numbers) { $out .= "\n\t\t<th>$row</th>"; } $colcount = $this->colcount($sheet); for ($col = 1; $col <= $colcount; $col++) { // Account for Rowspans/Colspans $rowspan = $this->rowspan($row, $col, $sheet); $colspan = $this->colspan($row, $col, $sheet); for ($i = 0; $i < $rowspan; $i++) { for ($j = 0; $j < $colspan; $j++) { if ($i > 0 || $j > 0) { $this->sheets[$sheet]['cellsInfo'][$row + $i][$col + $j]['dontprint'] = 1; } } } if (!isset($this->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']) || !$this->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']) { $style = $this->getCssStyle($row, $col, $sheet); if ($this->colhidden($col, $sheet)) { $style .= "display:none;"; } $out .= "\n\t\t<td style=\"$style\"" . ($colspan > 1 ? " colspan=$colspan" : "") . ($rowspan > 1 ? " rowspan=$rowspan" : "") . ">"; $val = $this->val($row, $col, $sheet); if ($val == '') { $val = "&nbsp;"; } else { $val = htmlentities($val, ENT_NOQUOTES, 'utf-8'); $link = $this->hyperlink($row, $col, $sheet); if ($link != '') { $val = "<a href=\"$link\">$val</a>"; } } $out .= "<nobr>" . nl2br($val) . "</nobr>"; $out .= "</td>"; } } $out .= "</tr>\n"; } $out .= "</tbody></table>"; return $out; }
[ "public", "function", "toHtml", "(", "$", "row_numbers", "=", "false", ",", "$", "col_letters", "=", "false", ",", "$", "sheet", "=", "0", ",", "$", "table_class", "=", "'excel'", ")", "{", "$", "out", "=", "\"<table class=\\\"$table_class\\\" cellspacing=0>\"", ";", "if", "(", "$", "col_letters", ")", "{", "$", "out", ".=", "\"<thead>\\n\\t<tr>\"", ";", "if", "(", "$", "row_numbers", ")", "{", "$", "out", ".=", "\"\\n\\t\\t<th>&nbsp</th>\"", ";", "}", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "this", "->", "colcount", "(", "$", "sheet", ")", ";", "$", "i", "++", ")", "{", "$", "style", "=", "\"width:\"", ".", "(", "$", "this", "->", "colwidth", "(", "$", "i", ",", "$", "sheet", ")", "*", "1", ")", ".", "\"px;\"", ";", "if", "(", "$", "this", "->", "colhidden", "(", "$", "i", ",", "$", "sheet", ")", ")", "{", "$", "style", ".=", "\"display:none;\"", ";", "}", "$", "out", ".=", "\"\\n\\t\\t<th style=\\\"$style\\\">\"", ".", "strtoupper", "(", "$", "this", "->", "colindexes", "[", "$", "i", "]", ")", ".", "\"</th>\"", ";", "}", "$", "out", ".=", "\"</tr></thead>\\n\"", ";", "}", "$", "out", ".=", "\"<tbody>\\n\"", ";", "$", "row_count", "=", "$", "this", "->", "rowcount", "(", "$", "sheet", ")", ";", "for", "(", "$", "row", "=", "1", ";", "$", "row", "<=", "$", "this", "->", "rowcount", "(", "$", "sheet", ")", ";", "$", "row", "++", ")", "{", "$", "rowheight", "=", "$", "this", "->", "rowheight", "(", "$", "row", ",", "$", "sheet", ")", ";", "$", "style", "=", "\"height:\"", ".", "(", "$", "rowheight", "*", "(", "4", "/", "3", ")", ")", ".", "\"px;\"", ";", "if", "(", "$", "this", "->", "rowhidden", "(", "$", "row", ",", "$", "sheet", ")", ")", "{", "$", "style", ".=", "\"display:none;\"", ";", "}", "$", "out", ".=", "\"\\n\\t<tr style=\\\"$style\\\">\"", ";", "if", "(", "$", "row_numbers", ")", "{", "$", "out", ".=", "\"\\n\\t\\t<th>$row</th>\"", ";", "}", "$", "colcount", "=", "$", "this", "->", "colcount", "(", "$", "sheet", ")", ";", "for", "(", "$", "col", "=", "1", ";", "$", "col", "<=", "$", "colcount", ";", "$", "col", "++", ")", "{", "// Account for Rowspans/Colspans", "$", "rowspan", "=", "$", "this", "->", "rowspan", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "$", "colspan", "=", "$", "this", "->", "colspan", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "rowspan", ";", "$", "i", "++", ")", "{", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "colspan", ";", "$", "j", "++", ")", "{", "if", "(", "$", "i", ">", "0", "||", "$", "j", ">", "0", ")", "{", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "+", "$", "i", "]", "[", "$", "col", "+", "$", "j", "]", "[", "'dontprint'", "]", "=", "1", ";", "}", "}", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "'dontprint'", "]", ")", "||", "!", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "'dontprint'", "]", ")", "{", "$", "style", "=", "$", "this", "->", "getCssStyle", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "this", "->", "colhidden", "(", "$", "col", ",", "$", "sheet", ")", ")", "{", "$", "style", ".=", "\"display:none;\"", ";", "}", "$", "out", ".=", "\"\\n\\t\\t<td style=\\\"$style\\\"\"", ".", "(", "$", "colspan", ">", "1", "?", "\" colspan=$colspan\"", ":", "\"\"", ")", ".", "(", "$", "rowspan", ">", "1", "?", "\" rowspan=$rowspan\"", ":", "\"\"", ")", ".", "\">\"", ";", "$", "val", "=", "$", "this", "->", "val", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "val", "==", "''", ")", "{", "$", "val", "=", "\"&nbsp;\"", ";", "}", "else", "{", "$", "val", "=", "htmlentities", "(", "$", "val", ",", "ENT_NOQUOTES", ",", "'utf-8'", ")", ";", "$", "link", "=", "$", "this", "->", "hyperlink", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "if", "(", "$", "link", "!=", "''", ")", "{", "$", "val", "=", "\"<a href=\\\"$link\\\">$val</a>\"", ";", "}", "}", "$", "out", ".=", "\"<nobr>\"", ".", "nl2br", "(", "$", "val", ")", ".", "\"</nobr>\"", ";", "$", "out", ".=", "\"</td>\"", ";", "}", "}", "$", "out", ".=", "\"</tr>\\n\"", ";", "}", "$", "out", ".=", "\"</tbody></table>\"", ";", "return", "$", "out", ";", "}" ]
Dumps an HTML file representing xls data, removed htmlentities to allow for UTF chars @param boolean $row_numbers Should row numbers show @param boolean $col_letters Should col letters show @param integer $sheet Which sheet to dump @param string $table_class Which class to give the table @return string
[ "Dumps", "an", "HTML", "file", "representing", "xls", "data", "removed", "htmlentities", "to", "allow", "for", "UTF", "chars" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader/HTML.php#L314-L383
JBZoo/Assets
src/Collection.php
Collection.remove
public function remove($name) { $names = (array)$name; foreach ($names as $name) { if (Arr::key($name, $this->_assets)) { unset($this->_assets[$name]); } } }
php
public function remove($name) { $names = (array)$name; foreach ($names as $name) { if (Arr::key($name, $this->_assets)) { unset($this->_assets[$name]); } } }
[ "public", "function", "remove", "(", "$", "name", ")", "{", "$", "names", "=", "(", "array", ")", "$", "name", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "Arr", "::", "key", "(", "$", "name", ",", "$", "this", "->", "_assets", ")", ")", "{", "unset", "(", "$", "this", "->", "_assets", "[", "$", "name", "]", ")", ";", "}", "}", "}" ]
Removes assets from collection. @param string|array $name @return void
[ "Removes", "assets", "from", "collection", "." ]
train
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Collection.php#L82-L91
wilmoore/attributes.php
src/Attributes.php
Attributes.resetChangeHistory
function resetChangeHistory($attribute) { if ($this->propertyExists($attribute, 'changes')) { $this->setPropertyFor($attribute, 'changes', [], null, false); } return $this; }
php
function resetChangeHistory($attribute) { if ($this->propertyExists($attribute, 'changes')) { $this->setPropertyFor($attribute, 'changes', [], null, false); } return $this; }
[ "function", "resetChangeHistory", "(", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "propertyExists", "(", "$", "attribute", ",", "'changes'", ")", ")", "{", "$", "this", "->", "setPropertyFor", "(", "$", "attribute", ",", "'changes'", ",", "[", "]", ",", "null", ",", "false", ")", ";", "}", "return", "$", "this", ";", "}" ]
`resetChangeHistory` clears the change history for an attribute @param string $attribute attribute name @return $this
[ "resetChangeHistory", "clears", "the", "change", "history", "for", "an", "attribute" ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L48-L54
wilmoore/attributes.php
src/Attributes.php
Attributes.propertyExists
function propertyExists($attribute, $property) { return array_key_exists($attribute, $this->__attributes) && array_key_exists($property, $this->__attributes[$attribute]); }
php
function propertyExists($attribute, $property) { return array_key_exists($attribute, $this->__attributes) && array_key_exists($property, $this->__attributes[$attribute]); }
[ "function", "propertyExists", "(", "$", "attribute", ",", "$", "property", ")", "{", "return", "array_key_exists", "(", "$", "attribute", ",", "$", "this", "->", "__attributes", ")", "&&", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", ")", ";", "}" ]
`propertyExists` determines if an attribute property has been set. @param string $attribute attribute name @param string $property property name @api public @return boolean
[ "propertyExists", "determines", "if", "an", "attribute", "property", "has", "been", "set", "." ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L79-L82
wilmoore/attributes.php
src/Attributes.php
Attributes.get
function get($name, $default=null) { $map = array_map(function($name) use($default){ if ($this->__isset($name)) { return $this->__attributes[$name]['value']; } elseif ($this->propertyExists($name, 'default')) { return $this->__attributes[$name]['default']; } return (null === $default) ? null : $default; }, (array) $name); return count($map) > 1 ? $map : $map[0]; }
php
function get($name, $default=null) { $map = array_map(function($name) use($default){ if ($this->__isset($name)) { return $this->__attributes[$name]['value']; } elseif ($this->propertyExists($name, 'default')) { return $this->__attributes[$name]['default']; } return (null === $default) ? null : $default; }, (array) $name); return count($map) > 1 ? $map : $map[0]; }
[ "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "map", "=", "array_map", "(", "function", "(", "$", "name", ")", "use", "(", "$", "default", ")", "{", "if", "(", "$", "this", "->", "__isset", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "__attributes", "[", "$", "name", "]", "[", "'value'", "]", ";", "}", "elseif", "(", "$", "this", "->", "propertyExists", "(", "$", "name", ",", "'default'", ")", ")", "{", "return", "$", "this", "->", "__attributes", "[", "$", "name", "]", "[", "'default'", "]", ";", "}", "return", "(", "null", "===", "$", "default", ")", "?", "null", ":", "$", "default", ";", "}", ",", "(", "array", ")", "$", "name", ")", ";", "return", "count", "(", "$", "map", ")", ">", "1", "?", "$", "map", ":", "$", "map", "[", "0", "]", ";", "}" ]
`get` returns attributes value or, if attribute value is null, returns default value if given @param string $name attribute name @param mixed $default [optional] default return value @return mixed
[ "get", "returns", "attributes", "value", "or", "if", "attribute", "value", "is", "null", "returns", "default", "value", "if", "given" ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L109-L121
wilmoore/attributes.php
src/Attributes.php
Attributes.set
function set($attribute, $value = null) { $attributes = is_array($attribute) ? $attribute : [$attribute => $value]; foreach ($attributes as $attr => $val) { if ($this->getPropertyFor($attr, 'accepts')) { $acceptsConstraint = new Attributes\Constraint\Accepts($this->getPropertyFor($attr, 'accepts')); if (!$acceptsConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'minimum')) { $minimumConstraint = new Attributes\Constraint\Minimum($this->getPropertyFor($attr, 'minimum')); if (!$minimumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'maximum')) { $maximumConstraint = new Attributes\Constraint\Maximum($this->getPropertyFor($attr, 'maximum')); if (!$maximumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } $this->setPropertyFor($attr, 'value', $val, 'set'); } return $this; }
php
function set($attribute, $value = null) { $attributes = is_array($attribute) ? $attribute : [$attribute => $value]; foreach ($attributes as $attr => $val) { if ($this->getPropertyFor($attr, 'accepts')) { $acceptsConstraint = new Attributes\Constraint\Accepts($this->getPropertyFor($attr, 'accepts')); if (!$acceptsConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'minimum')) { $minimumConstraint = new Attributes\Constraint\Minimum($this->getPropertyFor($attr, 'minimum')); if (!$minimumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'maximum')) { $maximumConstraint = new Attributes\Constraint\Maximum($this->getPropertyFor($attr, 'maximum')); if (!$maximumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } $this->setPropertyFor($attr, 'value', $val, 'set'); } return $this; }
[ "function", "set", "(", "$", "attribute", ",", "$", "value", "=", "null", ")", "{", "$", "attributes", "=", "is_array", "(", "$", "attribute", ")", "?", "$", "attribute", ":", "[", "$", "attribute", "=>", "$", "value", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "attr", "=>", "$", "val", ")", "{", "if", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'accepts'", ")", ")", "{", "$", "acceptsConstraint", "=", "new", "Attributes", "\\", "Constraint", "\\", "Accepts", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'accepts'", ")", ")", ";", "if", "(", "!", "$", "acceptsConstraint", "->", "isValid", "(", "$", "val", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__CLASS__", ".", "\" does not accept {$val} as value for the property {$attr}\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'minimum'", ")", ")", "{", "$", "minimumConstraint", "=", "new", "Attributes", "\\", "Constraint", "\\", "Minimum", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'minimum'", ")", ")", ";", "if", "(", "!", "$", "minimumConstraint", "->", "isValid", "(", "$", "val", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__CLASS__", ".", "\" does not accept {$val} as value for the property {$attr}\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'maximum'", ")", ")", "{", "$", "maximumConstraint", "=", "new", "Attributes", "\\", "Constraint", "\\", "Maximum", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'maximum'", ")", ")", ";", "if", "(", "!", "$", "maximumConstraint", "->", "isValid", "(", "$", "val", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__CLASS__", ".", "\" does not accept {$val} as value for the property {$attr}\"", ")", ";", "}", "}", "$", "this", "->", "setPropertyFor", "(", "$", "attr", ",", "'value'", ",", "$", "val", ",", "'set'", ")", ";", "}", "return", "$", "this", ";", "}" ]
`set` attributes value @param string $attribute attribute name @param mixed $value attribute value @return $this
[ "set", "attributes", "value" ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L144-L176
wilmoore/attributes.php
src/Attributes.php
Attributes.push
function push($attribute, $value) { if (! $this->has($attribute)) { return $this; } $new = $this->get($attribute); if (! is_array($new) && !$new instanceof Traversable) { return $this; } $new[] = $value; $this->setPropertyFor($attribute, 'value', $new, 'push'); return $this; }
php
function push($attribute, $value) { if (! $this->has($attribute)) { return $this; } $new = $this->get($attribute); if (! is_array($new) && !$new instanceof Traversable) { return $this; } $new[] = $value; $this->setPropertyFor($attribute, 'value', $new, 'push'); return $this; }
[ "function", "push", "(", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "return", "$", "this", ";", "}", "$", "new", "=", "$", "this", "->", "get", "(", "$", "attribute", ")", ";", "if", "(", "!", "is_array", "(", "$", "new", ")", "&&", "!", "$", "new", "instanceof", "Traversable", ")", "{", "return", "$", "this", ";", "}", "$", "new", "[", "]", "=", "$", "value", ";", "$", "this", "->", "setPropertyFor", "(", "$", "attribute", ",", "'value'", ",", "$", "new", ",", "'push'", ")", ";", "return", "$", "this", ";", "}" ]
`push` a new value onto end of array @param string $attribute attribute name @param mixed $value attribute value @return $this
[ "push", "a", "new", "value", "onto", "end", "of", "array" ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L187-L202
wilmoore/attributes.php
src/Attributes.php
Attributes.getPropertyFor
private function getPropertyFor($attribute, $property) { return $this->propertyExists($attribute, $property) ? $this->__attributes[$attribute][$property] : null; }
php
private function getPropertyFor($attribute, $property) { return $this->propertyExists($attribute, $property) ? $this->__attributes[$attribute][$property] : null; }
[ "private", "function", "getPropertyFor", "(", "$", "attribute", ",", "$", "property", ")", "{", "return", "$", "this", "->", "propertyExists", "(", "$", "attribute", ",", "$", "property", ")", "?", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", "[", "$", "property", "]", ":", "null", ";", "}" ]
`getPropertyFor` returns an attribute property by name @param string $attribute attribute name @param string $property property name @return boolean
[ "getPropertyFor", "returns", "an", "attribute", "property", "by", "name" ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L239-L243
wilmoore/attributes.php
src/Attributes.php
Attributes.setPropertyFor
private function setPropertyFor($attribute, $property, $value, $action, $changeTracking = true) { if (! $this->has($attribute)) {return;} if ($changeTracking) { $this->__attributes[$attribute]['changes'][] = [ 'action' => $action, 'from' => $this->get($attribute), 'to' => $value, 'when' => new DateTime('now', new DateTimezone('UTC')) ]; } $this->__attributes[$attribute][$property] = $value; }
php
private function setPropertyFor($attribute, $property, $value, $action, $changeTracking = true) { if (! $this->has($attribute)) {return;} if ($changeTracking) { $this->__attributes[$attribute]['changes'][] = [ 'action' => $action, 'from' => $this->get($attribute), 'to' => $value, 'when' => new DateTime('now', new DateTimezone('UTC')) ]; } $this->__attributes[$attribute][$property] = $value; }
[ "private", "function", "setPropertyFor", "(", "$", "attribute", ",", "$", "property", ",", "$", "value", ",", "$", "action", ",", "$", "changeTracking", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "return", ";", "}", "if", "(", "$", "changeTracking", ")", "{", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", "[", "'changes'", "]", "[", "]", "=", "[", "'action'", "=>", "$", "action", ",", "'from'", "=>", "$", "this", "->", "get", "(", "$", "attribute", ")", ",", "'to'", "=>", "$", "value", ",", "'when'", "=>", "new", "DateTime", "(", "'now'", ",", "new", "DateTimezone", "(", "'UTC'", ")", ")", "]", ";", "}", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", "[", "$", "property", "]", "=", "$", "value", ";", "}" ]
`setPropertyFor` sets an attribute property value @param string $attribute attribute name @param string $property property name @param mixed $value property value @return boolean
[ "setPropertyFor", "sets", "an", "attribute", "property", "value" ]
train
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L255-L268
barrelstrength/craftnet-php
src/PluginLicenses.php
PluginLicenses.get
public function get(array $options = []) { $pagination = ''; if (isset($options['page']) && is_int($options['page'])) { $pagination = '?page='.$options['page']; } if (isset($options['key'])) { return $this->client->get('plugin-licenses/'.$options['key'].$pagination); } return $this->client->get('plugin-licenses'.$pagination); }
php
public function get(array $options = []) { $pagination = ''; if (isset($options['page']) && is_int($options['page'])) { $pagination = '?page='.$options['page']; } if (isset($options['key'])) { return $this->client->get('plugin-licenses/'.$options['key'].$pagination); } return $this->client->get('plugin-licenses'.$pagination); }
[ "public", "function", "get", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "pagination", "=", "''", ";", "if", "(", "isset", "(", "$", "options", "[", "'page'", "]", ")", "&&", "is_int", "(", "$", "options", "[", "'page'", "]", ")", ")", "{", "$", "pagination", "=", "'?page='", ".", "$", "options", "[", "'page'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'key'", "]", ")", ")", "{", "return", "$", "this", "->", "client", "->", "get", "(", "'plugin-licenses/'", ".", "$", "options", "[", "'key'", "]", ".", "$", "pagination", ")", ";", "}", "return", "$", "this", "->", "client", "->", "get", "(", "'plugin-licenses'", ".", "$", "pagination", ")", ";", "}" ]
Gets one or more licenses for the given Craft ID account @param array $options @return mixed|\Psr\Http\Message\ResponseInterface @throws \GuzzleHttp\Exception\GuzzleException
[ "Gets", "one", "or", "more", "licenses", "for", "the", "given", "Craft", "ID", "account" ]
train
https://github.com/barrelstrength/craftnet-php/blob/90c9767b6bef6078bc062b3bfcdde38b24c843fc/src/PluginLicenses.php#L30-L43
Velliz/pte
lib/Pte.php
Pte.RenderHtml
public function RenderHtml(&$Content, &$Data) { header('Content-Type: text/html'); foreach ($Content as $key => $val) { $datum = isset($Data[$val['key']]) ? $Data[$val['key']] : null; $hasChild = isset($val['child']) ? true : false; $this->_Output .= $val['text']; if ($this->CustomRender !== null) { $this->CustomRender->RegisterFunction($val['key'], $val['param']); $this->_Output .= $this->CustomRender->Parse(); } if ($val['param'] !== false) { if ($val['key'] === 'css') { $this->tempCss .= $val['param']; } if ($val['key'] === 'js') { $this->tempJs .= $val['param']; } if ($val['key'] === 'part') { if ($val['param'] === 'css') { $this->_Output .= $this->tempCss; } if ($val['param'] === 'js') { $this->_Output .= $this->tempJs; } } } if ($this->GetVarType($datum) === $this->STRINGS) { $this->_Output .= (string)$Data[$val['key']]; } else if ($this->GetVarType($datum) === $this->NUMERIC) { $this->_Output .= (double)$Data[$val['key']]; } else if ($this->GetVarType($datum) === $this->ARRAYS) { foreach ($datum as $k => $v) { if (is_array($v)) { //Numeric Array $this->RenderHtml($val['child'], $v); } else { //Associative Arrays $this->RenderHtml($val['child'], $datum); break; } } } else if ($this->GetVarType($datum) === $this->BOOLEANS) { if ($datum) { $this->RenderHtml($val['child'], $datum); } } else if ($this->GetVarType($datum) === $this->OBJECTS) { if ($datum instanceof Parts) { $datum->RegisterFunction($val['key'], $val['param']); if ($datum->tags === $datum->fnName) { //Append output $this->_Output .= $datum->Parse(); //Append property $this->tempCss .= $datum->pte->GetTempCss(); $this->tempJs .= $datum->pte->GetTempJs(); } } } else { if ($hasChild && $datum !== null) { $this->RenderHtml($val['child'], $datum); } } } return $this->_Output; }
php
public function RenderHtml(&$Content, &$Data) { header('Content-Type: text/html'); foreach ($Content as $key => $val) { $datum = isset($Data[$val['key']]) ? $Data[$val['key']] : null; $hasChild = isset($val['child']) ? true : false; $this->_Output .= $val['text']; if ($this->CustomRender !== null) { $this->CustomRender->RegisterFunction($val['key'], $val['param']); $this->_Output .= $this->CustomRender->Parse(); } if ($val['param'] !== false) { if ($val['key'] === 'css') { $this->tempCss .= $val['param']; } if ($val['key'] === 'js') { $this->tempJs .= $val['param']; } if ($val['key'] === 'part') { if ($val['param'] === 'css') { $this->_Output .= $this->tempCss; } if ($val['param'] === 'js') { $this->_Output .= $this->tempJs; } } } if ($this->GetVarType($datum) === $this->STRINGS) { $this->_Output .= (string)$Data[$val['key']]; } else if ($this->GetVarType($datum) === $this->NUMERIC) { $this->_Output .= (double)$Data[$val['key']]; } else if ($this->GetVarType($datum) === $this->ARRAYS) { foreach ($datum as $k => $v) { if (is_array($v)) { //Numeric Array $this->RenderHtml($val['child'], $v); } else { //Associative Arrays $this->RenderHtml($val['child'], $datum); break; } } } else if ($this->GetVarType($datum) === $this->BOOLEANS) { if ($datum) { $this->RenderHtml($val['child'], $datum); } } else if ($this->GetVarType($datum) === $this->OBJECTS) { if ($datum instanceof Parts) { $datum->RegisterFunction($val['key'], $val['param']); if ($datum->tags === $datum->fnName) { //Append output $this->_Output .= $datum->Parse(); //Append property $this->tempCss .= $datum->pte->GetTempCss(); $this->tempJs .= $datum->pte->GetTempJs(); } } } else { if ($hasChild && $datum !== null) { $this->RenderHtml($val['child'], $datum); } } } return $this->_Output; }
[ "public", "function", "RenderHtml", "(", "&", "$", "Content", ",", "&", "$", "Data", ")", "{", "header", "(", "'Content-Type: text/html'", ")", ";", "foreach", "(", "$", "Content", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "datum", "=", "isset", "(", "$", "Data", "[", "$", "val", "[", "'key'", "]", "]", ")", "?", "$", "Data", "[", "$", "val", "[", "'key'", "]", "]", ":", "null", ";", "$", "hasChild", "=", "isset", "(", "$", "val", "[", "'child'", "]", ")", "?", "true", ":", "false", ";", "$", "this", "->", "_Output", ".=", "$", "val", "[", "'text'", "]", ";", "if", "(", "$", "this", "->", "CustomRender", "!==", "null", ")", "{", "$", "this", "->", "CustomRender", "->", "RegisterFunction", "(", "$", "val", "[", "'key'", "]", ",", "$", "val", "[", "'param'", "]", ")", ";", "$", "this", "->", "_Output", ".=", "$", "this", "->", "CustomRender", "->", "Parse", "(", ")", ";", "}", "if", "(", "$", "val", "[", "'param'", "]", "!==", "false", ")", "{", "if", "(", "$", "val", "[", "'key'", "]", "===", "'css'", ")", "{", "$", "this", "->", "tempCss", ".=", "$", "val", "[", "'param'", "]", ";", "}", "if", "(", "$", "val", "[", "'key'", "]", "===", "'js'", ")", "{", "$", "this", "->", "tempJs", ".=", "$", "val", "[", "'param'", "]", ";", "}", "if", "(", "$", "val", "[", "'key'", "]", "===", "'part'", ")", "{", "if", "(", "$", "val", "[", "'param'", "]", "===", "'css'", ")", "{", "$", "this", "->", "_Output", ".=", "$", "this", "->", "tempCss", ";", "}", "if", "(", "$", "val", "[", "'param'", "]", "===", "'js'", ")", "{", "$", "this", "->", "_Output", ".=", "$", "this", "->", "tempJs", ";", "}", "}", "}", "if", "(", "$", "this", "->", "GetVarType", "(", "$", "datum", ")", "===", "$", "this", "->", "STRINGS", ")", "{", "$", "this", "->", "_Output", ".=", "(", "string", ")", "$", "Data", "[", "$", "val", "[", "'key'", "]", "]", ";", "}", "else", "if", "(", "$", "this", "->", "GetVarType", "(", "$", "datum", ")", "===", "$", "this", "->", "NUMERIC", ")", "{", "$", "this", "->", "_Output", ".=", "(", "double", ")", "$", "Data", "[", "$", "val", "[", "'key'", "]", "]", ";", "}", "else", "if", "(", "$", "this", "->", "GetVarType", "(", "$", "datum", ")", "===", "$", "this", "->", "ARRAYS", ")", "{", "foreach", "(", "$", "datum", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "//Numeric Array", "$", "this", "->", "RenderHtml", "(", "$", "val", "[", "'child'", "]", ",", "$", "v", ")", ";", "}", "else", "{", "//Associative Arrays", "$", "this", "->", "RenderHtml", "(", "$", "val", "[", "'child'", "]", ",", "$", "datum", ")", ";", "break", ";", "}", "}", "}", "else", "if", "(", "$", "this", "->", "GetVarType", "(", "$", "datum", ")", "===", "$", "this", "->", "BOOLEANS", ")", "{", "if", "(", "$", "datum", ")", "{", "$", "this", "->", "RenderHtml", "(", "$", "val", "[", "'child'", "]", ",", "$", "datum", ")", ";", "}", "}", "else", "if", "(", "$", "this", "->", "GetVarType", "(", "$", "datum", ")", "===", "$", "this", "->", "OBJECTS", ")", "{", "if", "(", "$", "datum", "instanceof", "Parts", ")", "{", "$", "datum", "->", "RegisterFunction", "(", "$", "val", "[", "'key'", "]", ",", "$", "val", "[", "'param'", "]", ")", ";", "if", "(", "$", "datum", "->", "tags", "===", "$", "datum", "->", "fnName", ")", "{", "//Append output", "$", "this", "->", "_Output", ".=", "$", "datum", "->", "Parse", "(", ")", ";", "//Append property", "$", "this", "->", "tempCss", ".=", "$", "datum", "->", "pte", "->", "GetTempCss", "(", ")", ";", "$", "this", "->", "tempJs", ".=", "$", "datum", "->", "pte", "->", "GetTempJs", "(", ")", ";", "}", "}", "}", "else", "{", "if", "(", "$", "hasChild", "&&", "$", "datum", "!==", "null", ")", "{", "$", "this", "->", "RenderHtml", "(", "$", "val", "[", "'child'", "]", ",", "$", "datum", ")", ";", "}", "}", "}", "return", "$", "this", "->", "_Output", ";", "}" ]
@param $Content @param $Data @return string content is template in array format @throws PteException Content is template in array format Data is returned date from controller
[ "@param", "$Content", "@param", "$Data", "@return", "string", "content", "is", "template", "in", "array", "format", "@throws", "PteException" ]
train
https://github.com/Velliz/pte/blob/8f8edc2289740d554a5942ff96eb727d838e866a/lib/Pte.php#L203-L274
surebert/surebert-framework
src/sb/CURL/Client/NTLM.php
NTLM.load
public function load($url, $data = null, $headers = null, $curl_opts = []) { if(!isset($curl_opts[CURLOPT_HTTP_VERSION])){ $curl_opts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; } if(!isset($curl_opts[CURLOPT_HTTPAUTH])){ $curl_opts[CURLOPT_HTTPAUTH] = CURLAUTH_NTLM; } if(!isset($curl_opts[CURLOPT_USERPWD])){ $curl_opts[CURLOPT_USERPWD] = $this->user . ':' . $this->pass; } return parent::load($url, $data, $headers, $curl_opts); }
php
public function load($url, $data = null, $headers = null, $curl_opts = []) { if(!isset($curl_opts[CURLOPT_HTTP_VERSION])){ $curl_opts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; } if(!isset($curl_opts[CURLOPT_HTTPAUTH])){ $curl_opts[CURLOPT_HTTPAUTH] = CURLAUTH_NTLM; } if(!isset($curl_opts[CURLOPT_USERPWD])){ $curl_opts[CURLOPT_USERPWD] = $this->user . ':' . $this->pass; } return parent::load($url, $data, $headers, $curl_opts); }
[ "public", "function", "load", "(", "$", "url", ",", "$", "data", "=", "null", ",", "$", "headers", "=", "null", ",", "$", "curl_opts", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "curl_opts", "[", "CURLOPT_HTTP_VERSION", "]", ")", ")", "{", "$", "curl_opts", "[", "CURLOPT_HTTP_VERSION", "]", "=", "CURL_HTTP_VERSION_1_1", ";", "}", "if", "(", "!", "isset", "(", "$", "curl_opts", "[", "CURLOPT_HTTPAUTH", "]", ")", ")", "{", "$", "curl_opts", "[", "CURLOPT_HTTPAUTH", "]", "=", "CURLAUTH_NTLM", ";", "}", "if", "(", "!", "isset", "(", "$", "curl_opts", "[", "CURLOPT_USERPWD", "]", ")", ")", "{", "$", "curl_opts", "[", "CURLOPT_USERPWD", "]", "=", "$", "this", "->", "user", ".", "':'", ".", "$", "this", "->", "pass", ";", "}", "return", "parent", "::", "load", "(", "$", "url", ",", "$", "data", ",", "$", "headers", ",", "$", "curl_opts", ")", ";", "}" ]
Loads a response from an NTLM service @param string $url The url to visit @param string/array $post The post data to send @param array $headers The headers to send @param array $curl_opts Any additional curl_opts to send @return string the response text @throws \Exception
[ "Loads", "a", "response", "from", "an", "NTLM", "service" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/CURL/Client/NTLM.php#L37-L52
phpnfe/tools
src/Certificado/Base.php
Base.pem2Der
protected static function pem2Der($pemData) { $begin = 'CERTIFICATE-----'; $end = '-----END'; //extrai o conteúdo do certificado entre as marcas BEGIN e END $pemData1 = substr($pemData, strpos($pemData, $begin) + strlen($begin)); $pemData2 = substr($pemData1, 0, strpos($pemData1, $end)); //converte o resultado para binário obtendo um certificado em formato DER $derData = base64_decode((string) $pemData2); return $derData; }
php
protected static function pem2Der($pemData) { $begin = 'CERTIFICATE-----'; $end = '-----END'; //extrai o conteúdo do certificado entre as marcas BEGIN e END $pemData1 = substr($pemData, strpos($pemData, $begin) + strlen($begin)); $pemData2 = substr($pemData1, 0, strpos($pemData1, $end)); //converte o resultado para binário obtendo um certificado em formato DER $derData = base64_decode((string) $pemData2); return $derData; }
[ "protected", "static", "function", "pem2Der", "(", "$", "pemData", ")", "{", "$", "begin", "=", "'CERTIFICATE-----'", ";", "$", "end", "=", "'-----END'", ";", "//extrai o conteúdo do certificado entre as marcas BEGIN e END", "$", "pemData1", "=", "substr", "(", "$", "pemData", ",", "strpos", "(", "$", "pemData", ",", "$", "begin", ")", "+", "strlen", "(", "$", "begin", ")", ")", ";", "$", "pemData2", "=", "substr", "(", "$", "pemData1", ",", "0", ",", "strpos", "(", "$", "pemData1", ",", "$", "end", ")", ")", ";", "//converte o resultado para binário obtendo um certificado em formato DER", "$", "derData", "=", "base64_decode", "(", "(", "string", ")", "$", "pemData2", ")", ";", "return", "$", "derData", ";", "}" ]
pem2Der Transforma o certificado do formato PEM para o formato DER. @param string $pem_data @return string
[ "pem2Der", "Transforma", "o", "certificado", "do", "formato", "PEM", "para", "o", "formato", "DER", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L12-L23
phpnfe/tools
src/Certificado/Base.php
Base.oidtoHex
protected static function oidtoHex($oid) { if ($oid == '') { return ''; } $abBinary = []; //coloca cada parte do numero do OID em uma linha da matriz $partes = explode('.', $oid); $bun = 0; //para cada numero compor o valor asc do mesmo for ($num = 0; $num < count($partes); $num++) { if ($num == 0) { $bun = 40 * $partes[$num]; } elseif ($num == 1) { $bun += $partes[$num]; $abBinary[] = $bun; } else { $abBinary = self::xBase128((array) $abBinary, (int) $partes[$num], true); } } $value = chr(0x06) . chr(count($abBinary)); //para cada item da matriz compor a string de retorno como caracter foreach ($abBinary as $item) { $value .= chr($item); } return $value; }
php
protected static function oidtoHex($oid) { if ($oid == '') { return ''; } $abBinary = []; //coloca cada parte do numero do OID em uma linha da matriz $partes = explode('.', $oid); $bun = 0; //para cada numero compor o valor asc do mesmo for ($num = 0; $num < count($partes); $num++) { if ($num == 0) { $bun = 40 * $partes[$num]; } elseif ($num == 1) { $bun += $partes[$num]; $abBinary[] = $bun; } else { $abBinary = self::xBase128((array) $abBinary, (int) $partes[$num], true); } } $value = chr(0x06) . chr(count($abBinary)); //para cada item da matriz compor a string de retorno como caracter foreach ($abBinary as $item) { $value .= chr($item); } return $value; }
[ "protected", "static", "function", "oidtoHex", "(", "$", "oid", ")", "{", "if", "(", "$", "oid", "==", "''", ")", "{", "return", "''", ";", "}", "$", "abBinary", "=", "[", "]", ";", "//coloca cada parte do numero do OID em uma linha da matriz", "$", "partes", "=", "explode", "(", "'.'", ",", "$", "oid", ")", ";", "$", "bun", "=", "0", ";", "//para cada numero compor o valor asc do mesmo", "for", "(", "$", "num", "=", "0", ";", "$", "num", "<", "count", "(", "$", "partes", ")", ";", "$", "num", "++", ")", "{", "if", "(", "$", "num", "==", "0", ")", "{", "$", "bun", "=", "40", "*", "$", "partes", "[", "$", "num", "]", ";", "}", "elseif", "(", "$", "num", "==", "1", ")", "{", "$", "bun", "+=", "$", "partes", "[", "$", "num", "]", ";", "$", "abBinary", "[", "]", "=", "$", "bun", ";", "}", "else", "{", "$", "abBinary", "=", "self", "::", "xBase128", "(", "(", "array", ")", "$", "abBinary", ",", "(", "int", ")", "$", "partes", "[", "$", "num", "]", ",", "true", ")", ";", "}", "}", "$", "value", "=", "chr", "(", "0x06", ")", ".", "chr", "(", "count", "(", "$", "abBinary", ")", ")", ";", "//para cada item da matriz compor a string de retorno como caracter", "foreach", "(", "$", "abBinary", "as", "$", "item", ")", "{", "$", "value", ".=", "chr", "(", "$", "item", ")", ";", "}", "return", "$", "value", ";", "}" ]
oidtoHex Converte o numero de identificação do OID em uma representação asc, coerente com o formato do certificado. @param string $oid numero OID (com os pontos de separação) @return string sequencia em hexadecimal
[ "oidtoHex", "Converte", "o", "numero", "de", "identificação", "do", "OID", "em", "uma", "representação", "asc", "coerente", "com", "o", "formato", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L33-L60
phpnfe/tools
src/Certificado/Base.php
Base.xBase128
protected static function xBase128($abIn, $qIn, $flag) { $abc = $abIn; if ($qIn > 127) { $abc = self::xBase128($abc, floor($qIn / 128), false); } $qIn2 = $qIn % 128; if ($flag) { $abc[] = $qIn2; } else { $abc[] = 0x80 | $qIn2; } return $abc; }
php
protected static function xBase128($abIn, $qIn, $flag) { $abc = $abIn; if ($qIn > 127) { $abc = self::xBase128($abc, floor($qIn / 128), false); } $qIn2 = $qIn % 128; if ($flag) { $abc[] = $qIn2; } else { $abc[] = 0x80 | $qIn2; } return $abc; }
[ "protected", "static", "function", "xBase128", "(", "$", "abIn", ",", "$", "qIn", ",", "$", "flag", ")", "{", "$", "abc", "=", "$", "abIn", ";", "if", "(", "$", "qIn", ">", "127", ")", "{", "$", "abc", "=", "self", "::", "xBase128", "(", "$", "abc", ",", "floor", "(", "$", "qIn", "/", "128", ")", ",", "false", ")", ";", "}", "$", "qIn2", "=", "$", "qIn", "%", "128", ";", "if", "(", "$", "flag", ")", "{", "$", "abc", "[", "]", "=", "$", "qIn2", ";", "}", "else", "{", "$", "abc", "[", "]", "=", "0x80", "|", "$", "qIn2", ";", "}", "return", "$", "abc", ";", "}" ]
xBase128 Retorna o dado convertido em asc. @param array $abIn @param int $qIn @param bool $flag @return int
[ "xBase128", "Retorna", "o", "dado", "convertido", "em", "asc", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L71-L85
phpnfe/tools
src/Certificado/Base.php
Base.printHex
protected static function printHex($value) { $tabVal = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; $hex = ''; for ($i = 0; $i < strlen($value); $i++) { $lsig = ord(substr($value, $i, 1)) % 16; $msig = (ord(substr($value, $i, 1)) - $lsig) / 16; $lessSig = $tabVal[$lsig]; $moreSig = $tabVal[$msig]; $hex .= $moreSig . $lessSig; } return $hex; }
php
protected static function printHex($value) { $tabVal = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; $hex = ''; for ($i = 0; $i < strlen($value); $i++) { $lsig = ord(substr($value, $i, 1)) % 16; $msig = (ord(substr($value, $i, 1)) - $lsig) / 16; $lessSig = $tabVal[$lsig]; $moreSig = $tabVal[$msig]; $hex .= $moreSig . $lessSig; } return $hex; }
[ "protected", "static", "function", "printHex", "(", "$", "value", ")", "{", "$", "tabVal", "=", "[", "'0'", ",", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "'5'", ",", "'6'", ",", "'7'", ",", "'8'", ",", "'9'", ",", "'A'", ",", "'B'", ",", "'C'", ",", "'D'", ",", "'E'", ",", "'F'", "]", ";", "$", "hex", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "value", ")", ";", "$", "i", "++", ")", "{", "$", "lsig", "=", "ord", "(", "substr", "(", "$", "value", ",", "$", "i", ",", "1", ")", ")", "%", "16", ";", "$", "msig", "=", "(", "ord", "(", "substr", "(", "$", "value", ",", "$", "i", ",", "1", ")", ")", "-", "$", "lsig", ")", "/", "16", ";", "$", "lessSig", "=", "$", "tabVal", "[", "$", "lsig", "]", ";", "$", "moreSig", "=", "$", "tabVal", "[", "$", "msig", "]", ";", "$", "hex", ".=", "$", "moreSig", ".", "$", "lessSig", ";", "}", "return", "$", "hex", ";", "}" ]
Retorna o valor em caracteres hexadecimais. @param string $value @return string @return void
[ "Retorna", "o", "valor", "em", "caracteres", "hexadecimais", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L94-L107
phpnfe/tools
src/Certificado/Base.php
Base.getLength
protected static function getLength(&$len, &$bytes, $data) { $len = ord($data[1]); $bytes = 0; // Testa se tamanho menor/igual a 127 bytes, // se for, então $len já é o tamanho do conteúdo if ($len & 0x80) { // Testa se tamanho indefinido (nao deve ocorrer em uma codificação DER) if ($len == chr(0x80)) { // Tamanho indefinido, limitado por 0x0000h $len = strpos($data, chr(0x00) . chr(0x00)); $bytes = 0; } else { //é tamanho definido. diz quantos bytes formam o tamanho $bytes = $len & 0x0f; $len = 0; for ($i = 0; $i < $bytes; $i++) { $len = ($len << 8) | ord($data[$i + 2]); } } } }
php
protected static function getLength(&$len, &$bytes, $data) { $len = ord($data[1]); $bytes = 0; // Testa se tamanho menor/igual a 127 bytes, // se for, então $len já é o tamanho do conteúdo if ($len & 0x80) { // Testa se tamanho indefinido (nao deve ocorrer em uma codificação DER) if ($len == chr(0x80)) { // Tamanho indefinido, limitado por 0x0000h $len = strpos($data, chr(0x00) . chr(0x00)); $bytes = 0; } else { //é tamanho definido. diz quantos bytes formam o tamanho $bytes = $len & 0x0f; $len = 0; for ($i = 0; $i < $bytes; $i++) { $len = ($len << 8) | ord($data[$i + 2]); } } } }
[ "protected", "static", "function", "getLength", "(", "&", "$", "len", ",", "&", "$", "bytes", ",", "$", "data", ")", "{", "$", "len", "=", "ord", "(", "$", "data", "[", "1", "]", ")", ";", "$", "bytes", "=", "0", ";", "// Testa se tamanho menor/igual a 127 bytes,", "// se for, então $len já é o tamanho do conteúdo", "if", "(", "$", "len", "&", "0x80", ")", "{", "// Testa se tamanho indefinido (nao deve ocorrer em uma codificação DER)", "if", "(", "$", "len", "==", "chr", "(", "0x80", ")", ")", "{", "// Tamanho indefinido, limitado por 0x0000h", "$", "len", "=", "strpos", "(", "$", "data", ",", "chr", "(", "0x00", ")", ".", "chr", "(", "0x00", ")", ")", ";", "$", "bytes", "=", "0", ";", "}", "else", "{", "//é tamanho definido. diz quantos bytes formam o tamanho", "$", "bytes", "=", "$", "len", "&", "0x0f", ";", "$", "len", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "bytes", ";", "$", "i", "++", ")", "{", "$", "len", "=", "(", "$", "len", "<<", "8", ")", "|", "ord", "(", "$", "data", "[", "$", "i", "+", "2", "]", ")", ";", "}", "}", "}", "}" ]
Obtêm o comprimento do conteúdo de uma sequência de dados do certificado. @param int $len variável passada por referência @param int $bytes variável passada por referência @param string $data campo a @return void
[ "Obtêm", "o", "comprimento", "do", "conteúdo", "de", "uma", "sequência", "de", "dados", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L117-L138
php-lug/lug
src/Component/Resource/Form/Type/Doctrine/ResourceChoiceType.php
ResourceChoiceType.configureOptions
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setRequired('resource') ->setAllowedTypes('resource', ResourceInterface::class) ->setDefaults([ 'class' => function (Options $options) { return $options['resource']->getModel(); }, 'choice_value' => function (Options $options) { return $options['resource']->getIdPropertyPath(); }, 'choice_label' => function (Options $options) { return $options['resource']->getLabelPropertyPath(); }, 'placeholder' => '', ]); }
php
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setRequired('resource') ->setAllowedTypes('resource', ResourceInterface::class) ->setDefaults([ 'class' => function (Options $options) { return $options['resource']->getModel(); }, 'choice_value' => function (Options $options) { return $options['resource']->getIdPropertyPath(); }, 'choice_label' => function (Options $options) { return $options['resource']->getLabelPropertyPath(); }, 'placeholder' => '', ]); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "parent", "::", "configureOptions", "(", "$", "resolver", ")", ";", "$", "resolver", "->", "setRequired", "(", "'resource'", ")", "->", "setAllowedTypes", "(", "'resource'", ",", "ResourceInterface", "::", "class", ")", "->", "setDefaults", "(", "[", "'class'", "=>", "function", "(", "Options", "$", "options", ")", "{", "return", "$", "options", "[", "'resource'", "]", "->", "getModel", "(", ")", ";", "}", ",", "'choice_value'", "=>", "function", "(", "Options", "$", "options", ")", "{", "return", "$", "options", "[", "'resource'", "]", "->", "getIdPropertyPath", "(", ")", ";", "}", ",", "'choice_label'", "=>", "function", "(", "Options", "$", "options", ")", "{", "return", "$", "options", "[", "'resource'", "]", "->", "getLabelPropertyPath", "(", ")", ";", "}", ",", "'placeholder'", "=>", "''", ",", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Form/Type/Doctrine/ResourceChoiceType.php#L27-L46
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Controller/ModelManager.php
Aoe_Layout_Controller_ModelManager.newAction
public function newAction() { $model = $this->loadModel(); if (!$model->isObjectNew()) { $this->_forward('noroute'); return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); try { $model->isObjectNew(true); foreach ($this->preprocessPostData($postData) as $key => $value) { $model->setDataUsingMethod($key, $value); } $model->save(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Saved Successfully'); return; } catch (Exception $e) { $message = $e->getMessage(); if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { /** @var PDOException $e */ $e = $e->getChainedException(); if (isset($e->errorInfo[0]) && $e->errorInfo[0] == 23000 && isset($e->errorInfo[1]) && $e->errorInfo[1] == 1062) { $message = $this->getHelper()->__( "Record already exists for %s '%s'", $model->getIdFieldName(), $model->getId() ); } } Mage::logException($e); $this->_getSession()->addError($message); } } $this->loadLayout(); $this->renderLayout(); }
php
public function newAction() { $model = $this->loadModel(); if (!$model->isObjectNew()) { $this->_forward('noroute'); return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); try { $model->isObjectNew(true); foreach ($this->preprocessPostData($postData) as $key => $value) { $model->setDataUsingMethod($key, $value); } $model->save(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Saved Successfully'); return; } catch (Exception $e) { $message = $e->getMessage(); if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { /** @var PDOException $e */ $e = $e->getChainedException(); if (isset($e->errorInfo[0]) && $e->errorInfo[0] == 23000 && isset($e->errorInfo[1]) && $e->errorInfo[1] == 1062) { $message = $this->getHelper()->__( "Record already exists for %s '%s'", $model->getIdFieldName(), $model->getId() ); } } Mage::logException($e); $this->_getSession()->addError($message); } } $this->loadLayout(); $this->renderLayout(); }
[ "public", "function", "newAction", "(", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", ")", ";", "if", "(", "!", "$", "model", "->", "isObjectNew", "(", ")", ")", "{", "$", "this", "->", "_forward", "(", "'noroute'", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "postData", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", ")", ";", "try", "{", "$", "model", "->", "isObjectNew", "(", "true", ")", ";", "foreach", "(", "$", "this", "->", "preprocessPostData", "(", "$", "postData", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "model", "->", "setDataUsingMethod", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "model", "->", "save", "(", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getGridUrl", "(", ")", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addSuccess", "(", "'Saved Successfully'", ")", ";", "return", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "if", "(", "$", "e", "instanceof", "Zend_Db_Statement_Exception", "&&", "$", "e", "->", "getChainedException", "(", ")", "instanceof", "PDOException", ")", "{", "/** @var PDOException $e */", "$", "e", "=", "$", "e", "->", "getChainedException", "(", ")", ";", "if", "(", "isset", "(", "$", "e", "->", "errorInfo", "[", "0", "]", ")", "&&", "$", "e", "->", "errorInfo", "[", "0", "]", "==", "23000", "&&", "isset", "(", "$", "e", "->", "errorInfo", "[", "1", "]", ")", "&&", "$", "e", "->", "errorInfo", "[", "1", "]", "==", "1062", ")", "{", "$", "message", "=", "$", "this", "->", "getHelper", "(", ")", "->", "__", "(", "\"Record already exists for %s '%s'\"", ",", "$", "model", "->", "getIdFieldName", "(", ")", ",", "$", "model", "->", "getId", "(", ")", ")", ";", "}", "}", "Mage", "::", "logException", "(", "$", "e", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addError", "(", "$", "message", ")", ";", "}", "}", "$", "this", "->", "loadLayout", "(", ")", ";", "$", "this", "->", "renderLayout", "(", ")", ";", "}" ]
Create a new record
[ "Create", "a", "new", "record" ]
train
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/ModelManager.php#L7-L46
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Controller/ModelManager.php
Aoe_Layout_Controller_ModelManager.editAction
public function editAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); try { foreach ($this->preprocessPostData($postData) as $key => $value) { $model->setDataUsingMethod($key, $value); } $model->save(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Saved Successfully'); return; } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
php
public function editAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); try { foreach ($this->preprocessPostData($postData) as $key => $value) { $model->setDataUsingMethod($key, $value); } $model->save(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Saved Successfully'); return; } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
[ "public", "function", "editAction", "(", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", ")", ";", "if", "(", "$", "model", "->", "isObjectNew", "(", ")", ")", "{", "$", "this", "->", "_forward", "(", "'noroute'", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "postData", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "preprocessPostData", "(", "$", "postData", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "model", "->", "setDataUsingMethod", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "model", "->", "save", "(", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getGridUrl", "(", ")", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addSuccess", "(", "'Saved Successfully'", ")", ";", "return", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "Zend_Db_Statement_Exception", "&&", "$", "e", "->", "getChainedException", "(", ")", "instanceof", "PDOException", ")", "{", "$", "e", "=", "$", "e", "->", "getChainedException", "(", ")", ";", "}", "Mage", "::", "logException", "(", "$", "e", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "$", "this", "->", "loadLayout", "(", ")", ";", "$", "this", "->", "renderLayout", "(", ")", ";", "}" ]
Edit an existing record
[ "Edit", "an", "existing", "record" ]
train
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/ModelManager.php#L51-L80
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Controller/ModelManager.php
Aoe_Layout_Controller_ModelManager.deleteAction
public function deleteAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } try { $model->delete(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Deleted Successfully'); } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); $this->_redirectUrl($this->getHelper()->getEditUrl($model)); } }
php
public function deleteAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } try { $model->delete(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Deleted Successfully'); } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); $this->_redirectUrl($this->getHelper()->getEditUrl($model)); } }
[ "public", "function", "deleteAction", "(", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", ")", ";", "if", "(", "$", "model", "->", "isObjectNew", "(", ")", ")", "{", "$", "this", "->", "_forward", "(", "'noroute'", ")", ";", "return", ";", "}", "try", "{", "$", "model", "->", "delete", "(", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getGridUrl", "(", ")", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addSuccess", "(", "'Deleted Successfully'", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "Zend_Db_Statement_Exception", "&&", "$", "e", "->", "getChainedException", "(", ")", "instanceof", "PDOException", ")", "{", "$", "e", "=", "$", "e", "->", "getChainedException", "(", ")", ";", "}", "Mage", "::", "logException", "(", "$", "e", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getEditUrl", "(", "$", "model", ")", ")", ";", "}", "}" ]
Delete an existing record
[ "Delete", "an", "existing", "record" ]
train
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/ModelManager.php#L85-L105
mothership-ec/composer
src/Composer/Installer.php
Installer.run
public function run() { gc_collect_cycles(); gc_disable(); if ($this->dryRun) { $this->verbose = true; $this->runScripts = false; $this->installationManager->addInstaller(new NoopInstaller); $this->mockLocalRepositories($this->repositoryManager); } // TODO remove this BC feature at some point // purge old require-dev packages to avoid conflicts with the new way of handling dev requirements $devRepo = new InstalledFilesystemRepository(new JsonFile($this->config->get('vendor-dir').'/composer/installed_dev.json')); if ($devRepo->getPackages()) { $this->io->writeError('<warning>BC Notice: Removing old dev packages to migrate to the new require-dev handling.</warning>'); foreach ($devRepo->getPackages() as $package) { if ($this->installationManager->isPackageInstalled($devRepo, $package)) { $this->installationManager->uninstall($devRepo, new UninstallOperation($package)); } } unlink($this->config->get('vendor-dir').'/composer/installed_dev.json'); } unset($devRepo, $package); // end BC if ($this->runScripts) { // dispatch pre event $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD; $this->eventDispatcher->dispatchScript($eventName, $this->devMode); } $this->downloadManager->setPreferSource($this->preferSource); $this->downloadManager->setPreferDist($this->preferDist); // clone root package to have one in the installed repo that does not require anything // we don't want it to be uninstallable, but its requirements should not conflict // with the lock file for example $installedRootPackage = clone $this->package; $installedRootPackage->setRequires(array()); $installedRootPackage->setDevRequires(array()); // create installed repo, this contains all local packages + platform packages (php & extensions) $localRepo = $this->repositoryManager->getLocalRepository(); if (!$this->update && $this->locker->isLocked()) { $platformOverrides = $this->locker->getPlatformOverrides(); } else { $platformOverrides = $this->config->get('platform') ?: array(); } $platformRepo = new PlatformRepository(array(), $platformOverrides); $repos = array( $localRepo, new InstalledArrayRepository(array($installedRootPackage)), $platformRepo, ); $installedRepo = new CompositeRepository($repos); if ($this->additionalInstalledRepository) { $installedRepo->addRepository($this->additionalInstalledRepository); } $aliases = $this->getRootAliases(); $this->aliasPlatformPackages($platformRepo, $aliases); try { $this->suggestedPackages = array(); $res = $this->doInstall($localRepo, $installedRepo, $platformRepo, $aliases, $this->devMode); if ($res !== 0) { return $res; } } catch (\Exception $e) { $this->installationManager->notifyInstalls(); throw $e; } $this->installationManager->notifyInstalls(); // output suggestions if we're in dev mode if ($this->devMode) { foreach ($this->suggestedPackages as $suggestion) { $target = $suggestion['target']; foreach ($installedRepo->getPackages() as $package) { if (in_array($target, $package->getNames())) { continue 2; } } $this->io->writeError($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')'); } } # Find abandoned packages and warn user foreach ($localRepo->getPackages() as $package) { if (!$package instanceof CompletePackage || !$package->isAbandoned()) { continue; } $replacement = (is_string($package->getReplacementPackage())) ? 'Use ' . $package->getReplacementPackage() . ' instead' : 'No replacement was suggested'; $this->io->writeError( sprintf( "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>", $package->getPrettyName(), $replacement ) ); } if (!$this->dryRun) { // write lock if ($this->update || !$this->locker->isLocked()) { $localRepo->reload(); // if this is not run in dev mode and the root has dev requires, the lock must // contain null to prevent dev installs from a non-dev lock $devPackages = ($this->devMode || !$this->package->getDevRequires()) ? array() : null; // split dev and non-dev requirements by checking what would be removed if we update without the dev requirements if ($this->devMode && $this->package->getDevRequires()) { $policy = $this->createPolicy(); $pool = $this->createPool(true); $pool->addRepository($installedRepo, $aliases); // creating requirements request $request = $this->createRequest($this->package, $platformRepo); $request->updateAll(); foreach ($this->package->getRequires() as $link) { $request->install($link->getTarget(), $link->getConstraint()); } $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request); $solver = new Solver($policy, $pool, $installedRepo); $ops = $solver->solve($request, $this->ignorePlatformReqs); $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request, $ops); foreach ($ops as $op) { if ($op->getJobType() === 'uninstall') { $devPackages[] = $op->getPackage(); } } } $platformReqs = $this->extractPlatformRequirements($this->package->getRequires()); $platformDevReqs = $this->devMode ? $this->extractPlatformRequirements($this->package->getDevRequires()) : array(); $updatedLock = $this->locker->setLockData( array_diff($localRepo->getCanonicalPackages(), (array) $devPackages), $devPackages, $platformReqs, $platformDevReqs, $aliases, $this->package->getMinimumStability(), $this->package->getStabilityFlags(), $this->preferStable || $this->package->getPreferStable(), $this->preferLowest, $this->config->get('platform') ?: array() ); if ($updatedLock) { $this->io->writeError('<info>Writing lock file</info>'); } } if ($this->dumpAutoloader) { // write autoloader if ($this->optimizeAutoloader) { $this->io->writeError('<info>Generating optimized autoload files</info>'); } else { $this->io->writeError('<info>Generating autoload files</info>'); } $this->autoloadGenerator->setDevMode($this->devMode); $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader); } if ($this->runScripts) { // dispatch post event $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; $this->eventDispatcher->dispatchScript($eventName, $this->devMode); } $vendorDir = $this->config->get('vendor-dir'); if (is_dir($vendorDir)) { touch($vendorDir); } } return 0; }
php
public function run() { gc_collect_cycles(); gc_disable(); if ($this->dryRun) { $this->verbose = true; $this->runScripts = false; $this->installationManager->addInstaller(new NoopInstaller); $this->mockLocalRepositories($this->repositoryManager); } // TODO remove this BC feature at some point // purge old require-dev packages to avoid conflicts with the new way of handling dev requirements $devRepo = new InstalledFilesystemRepository(new JsonFile($this->config->get('vendor-dir').'/composer/installed_dev.json')); if ($devRepo->getPackages()) { $this->io->writeError('<warning>BC Notice: Removing old dev packages to migrate to the new require-dev handling.</warning>'); foreach ($devRepo->getPackages() as $package) { if ($this->installationManager->isPackageInstalled($devRepo, $package)) { $this->installationManager->uninstall($devRepo, new UninstallOperation($package)); } } unlink($this->config->get('vendor-dir').'/composer/installed_dev.json'); } unset($devRepo, $package); // end BC if ($this->runScripts) { // dispatch pre event $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD; $this->eventDispatcher->dispatchScript($eventName, $this->devMode); } $this->downloadManager->setPreferSource($this->preferSource); $this->downloadManager->setPreferDist($this->preferDist); // clone root package to have one in the installed repo that does not require anything // we don't want it to be uninstallable, but its requirements should not conflict // with the lock file for example $installedRootPackage = clone $this->package; $installedRootPackage->setRequires(array()); $installedRootPackage->setDevRequires(array()); // create installed repo, this contains all local packages + platform packages (php & extensions) $localRepo = $this->repositoryManager->getLocalRepository(); if (!$this->update && $this->locker->isLocked()) { $platformOverrides = $this->locker->getPlatformOverrides(); } else { $platformOverrides = $this->config->get('platform') ?: array(); } $platformRepo = new PlatformRepository(array(), $platformOverrides); $repos = array( $localRepo, new InstalledArrayRepository(array($installedRootPackage)), $platformRepo, ); $installedRepo = new CompositeRepository($repos); if ($this->additionalInstalledRepository) { $installedRepo->addRepository($this->additionalInstalledRepository); } $aliases = $this->getRootAliases(); $this->aliasPlatformPackages($platformRepo, $aliases); try { $this->suggestedPackages = array(); $res = $this->doInstall($localRepo, $installedRepo, $platformRepo, $aliases, $this->devMode); if ($res !== 0) { return $res; } } catch (\Exception $e) { $this->installationManager->notifyInstalls(); throw $e; } $this->installationManager->notifyInstalls(); // output suggestions if we're in dev mode if ($this->devMode) { foreach ($this->suggestedPackages as $suggestion) { $target = $suggestion['target']; foreach ($installedRepo->getPackages() as $package) { if (in_array($target, $package->getNames())) { continue 2; } } $this->io->writeError($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')'); } } # Find abandoned packages and warn user foreach ($localRepo->getPackages() as $package) { if (!$package instanceof CompletePackage || !$package->isAbandoned()) { continue; } $replacement = (is_string($package->getReplacementPackage())) ? 'Use ' . $package->getReplacementPackage() . ' instead' : 'No replacement was suggested'; $this->io->writeError( sprintf( "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>", $package->getPrettyName(), $replacement ) ); } if (!$this->dryRun) { // write lock if ($this->update || !$this->locker->isLocked()) { $localRepo->reload(); // if this is not run in dev mode and the root has dev requires, the lock must // contain null to prevent dev installs from a non-dev lock $devPackages = ($this->devMode || !$this->package->getDevRequires()) ? array() : null; // split dev and non-dev requirements by checking what would be removed if we update without the dev requirements if ($this->devMode && $this->package->getDevRequires()) { $policy = $this->createPolicy(); $pool = $this->createPool(true); $pool->addRepository($installedRepo, $aliases); // creating requirements request $request = $this->createRequest($this->package, $platformRepo); $request->updateAll(); foreach ($this->package->getRequires() as $link) { $request->install($link->getTarget(), $link->getConstraint()); } $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request); $solver = new Solver($policy, $pool, $installedRepo); $ops = $solver->solve($request, $this->ignorePlatformReqs); $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request, $ops); foreach ($ops as $op) { if ($op->getJobType() === 'uninstall') { $devPackages[] = $op->getPackage(); } } } $platformReqs = $this->extractPlatformRequirements($this->package->getRequires()); $platformDevReqs = $this->devMode ? $this->extractPlatformRequirements($this->package->getDevRequires()) : array(); $updatedLock = $this->locker->setLockData( array_diff($localRepo->getCanonicalPackages(), (array) $devPackages), $devPackages, $platformReqs, $platformDevReqs, $aliases, $this->package->getMinimumStability(), $this->package->getStabilityFlags(), $this->preferStable || $this->package->getPreferStable(), $this->preferLowest, $this->config->get('platform') ?: array() ); if ($updatedLock) { $this->io->writeError('<info>Writing lock file</info>'); } } if ($this->dumpAutoloader) { // write autoloader if ($this->optimizeAutoloader) { $this->io->writeError('<info>Generating optimized autoload files</info>'); } else { $this->io->writeError('<info>Generating autoload files</info>'); } $this->autoloadGenerator->setDevMode($this->devMode); $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader); } if ($this->runScripts) { // dispatch post event $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; $this->eventDispatcher->dispatchScript($eventName, $this->devMode); } $vendorDir = $this->config->get('vendor-dir'); if (is_dir($vendorDir)) { touch($vendorDir); } } return 0; }
[ "public", "function", "run", "(", ")", "{", "gc_collect_cycles", "(", ")", ";", "gc_disable", "(", ")", ";", "if", "(", "$", "this", "->", "dryRun", ")", "{", "$", "this", "->", "verbose", "=", "true", ";", "$", "this", "->", "runScripts", "=", "false", ";", "$", "this", "->", "installationManager", "->", "addInstaller", "(", "new", "NoopInstaller", ")", ";", "$", "this", "->", "mockLocalRepositories", "(", "$", "this", "->", "repositoryManager", ")", ";", "}", "// TODO remove this BC feature at some point", "// purge old require-dev packages to avoid conflicts with the new way of handling dev requirements", "$", "devRepo", "=", "new", "InstalledFilesystemRepository", "(", "new", "JsonFile", "(", "$", "this", "->", "config", "->", "get", "(", "'vendor-dir'", ")", ".", "'/composer/installed_dev.json'", ")", ")", ";", "if", "(", "$", "devRepo", "->", "getPackages", "(", ")", ")", "{", "$", "this", "->", "io", "->", "writeError", "(", "'<warning>BC Notice: Removing old dev packages to migrate to the new require-dev handling.</warning>'", ")", ";", "foreach", "(", "$", "devRepo", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "if", "(", "$", "this", "->", "installationManager", "->", "isPackageInstalled", "(", "$", "devRepo", ",", "$", "package", ")", ")", "{", "$", "this", "->", "installationManager", "->", "uninstall", "(", "$", "devRepo", ",", "new", "UninstallOperation", "(", "$", "package", ")", ")", ";", "}", "}", "unlink", "(", "$", "this", "->", "config", "->", "get", "(", "'vendor-dir'", ")", ".", "'/composer/installed_dev.json'", ")", ";", "}", "unset", "(", "$", "devRepo", ",", "$", "package", ")", ";", "// end BC", "if", "(", "$", "this", "->", "runScripts", ")", "{", "// dispatch pre event", "$", "eventName", "=", "$", "this", "->", "update", "?", "ScriptEvents", "::", "PRE_UPDATE_CMD", ":", "ScriptEvents", "::", "PRE_INSTALL_CMD", ";", "$", "this", "->", "eventDispatcher", "->", "dispatchScript", "(", "$", "eventName", ",", "$", "this", "->", "devMode", ")", ";", "}", "$", "this", "->", "downloadManager", "->", "setPreferSource", "(", "$", "this", "->", "preferSource", ")", ";", "$", "this", "->", "downloadManager", "->", "setPreferDist", "(", "$", "this", "->", "preferDist", ")", ";", "// clone root package to have one in the installed repo that does not require anything", "// we don't want it to be uninstallable, but its requirements should not conflict", "// with the lock file for example", "$", "installedRootPackage", "=", "clone", "$", "this", "->", "package", ";", "$", "installedRootPackage", "->", "setRequires", "(", "array", "(", ")", ")", ";", "$", "installedRootPackage", "->", "setDevRequires", "(", "array", "(", ")", ")", ";", "// create installed repo, this contains all local packages + platform packages (php & extensions)", "$", "localRepo", "=", "$", "this", "->", "repositoryManager", "->", "getLocalRepository", "(", ")", ";", "if", "(", "!", "$", "this", "->", "update", "&&", "$", "this", "->", "locker", "->", "isLocked", "(", ")", ")", "{", "$", "platformOverrides", "=", "$", "this", "->", "locker", "->", "getPlatformOverrides", "(", ")", ";", "}", "else", "{", "$", "platformOverrides", "=", "$", "this", "->", "config", "->", "get", "(", "'platform'", ")", "?", ":", "array", "(", ")", ";", "}", "$", "platformRepo", "=", "new", "PlatformRepository", "(", "array", "(", ")", ",", "$", "platformOverrides", ")", ";", "$", "repos", "=", "array", "(", "$", "localRepo", ",", "new", "InstalledArrayRepository", "(", "array", "(", "$", "installedRootPackage", ")", ")", ",", "$", "platformRepo", ",", ")", ";", "$", "installedRepo", "=", "new", "CompositeRepository", "(", "$", "repos", ")", ";", "if", "(", "$", "this", "->", "additionalInstalledRepository", ")", "{", "$", "installedRepo", "->", "addRepository", "(", "$", "this", "->", "additionalInstalledRepository", ")", ";", "}", "$", "aliases", "=", "$", "this", "->", "getRootAliases", "(", ")", ";", "$", "this", "->", "aliasPlatformPackages", "(", "$", "platformRepo", ",", "$", "aliases", ")", ";", "try", "{", "$", "this", "->", "suggestedPackages", "=", "array", "(", ")", ";", "$", "res", "=", "$", "this", "->", "doInstall", "(", "$", "localRepo", ",", "$", "installedRepo", ",", "$", "platformRepo", ",", "$", "aliases", ",", "$", "this", "->", "devMode", ")", ";", "if", "(", "$", "res", "!==", "0", ")", "{", "return", "$", "res", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "installationManager", "->", "notifyInstalls", "(", ")", ";", "throw", "$", "e", ";", "}", "$", "this", "->", "installationManager", "->", "notifyInstalls", "(", ")", ";", "// output suggestions if we're in dev mode", "if", "(", "$", "this", "->", "devMode", ")", "{", "foreach", "(", "$", "this", "->", "suggestedPackages", "as", "$", "suggestion", ")", "{", "$", "target", "=", "$", "suggestion", "[", "'target'", "]", ";", "foreach", "(", "$", "installedRepo", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "if", "(", "in_array", "(", "$", "target", ",", "$", "package", "->", "getNames", "(", ")", ")", ")", "{", "continue", "2", ";", "}", "}", "$", "this", "->", "io", "->", "writeError", "(", "$", "suggestion", "[", "'source'", "]", ".", "' suggests installing '", ".", "$", "suggestion", "[", "'target'", "]", ".", "' ('", ".", "$", "suggestion", "[", "'reason'", "]", ".", "')'", ")", ";", "}", "}", "# Find abandoned packages and warn user", "foreach", "(", "$", "localRepo", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "if", "(", "!", "$", "package", "instanceof", "CompletePackage", "||", "!", "$", "package", "->", "isAbandoned", "(", ")", ")", "{", "continue", ";", "}", "$", "replacement", "=", "(", "is_string", "(", "$", "package", "->", "getReplacementPackage", "(", ")", ")", ")", "?", "'Use '", ".", "$", "package", "->", "getReplacementPackage", "(", ")", ".", "' instead'", ":", "'No replacement was suggested'", ";", "$", "this", "->", "io", "->", "writeError", "(", "sprintf", "(", "\"<warning>Package %s is abandoned, you should avoid using it. %s.</warning>\"", ",", "$", "package", "->", "getPrettyName", "(", ")", ",", "$", "replacement", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "dryRun", ")", "{", "// write lock", "if", "(", "$", "this", "->", "update", "||", "!", "$", "this", "->", "locker", "->", "isLocked", "(", ")", ")", "{", "$", "localRepo", "->", "reload", "(", ")", ";", "// if this is not run in dev mode and the root has dev requires, the lock must", "// contain null to prevent dev installs from a non-dev lock", "$", "devPackages", "=", "(", "$", "this", "->", "devMode", "||", "!", "$", "this", "->", "package", "->", "getDevRequires", "(", ")", ")", "?", "array", "(", ")", ":", "null", ";", "// split dev and non-dev requirements by checking what would be removed if we update without the dev requirements", "if", "(", "$", "this", "->", "devMode", "&&", "$", "this", "->", "package", "->", "getDevRequires", "(", ")", ")", "{", "$", "policy", "=", "$", "this", "->", "createPolicy", "(", ")", ";", "$", "pool", "=", "$", "this", "->", "createPool", "(", "true", ")", ";", "$", "pool", "->", "addRepository", "(", "$", "installedRepo", ",", "$", "aliases", ")", ";", "// creating requirements request", "$", "request", "=", "$", "this", "->", "createRequest", "(", "$", "this", "->", "package", ",", "$", "platformRepo", ")", ";", "$", "request", "->", "updateAll", "(", ")", ";", "foreach", "(", "$", "this", "->", "package", "->", "getRequires", "(", ")", "as", "$", "link", ")", "{", "$", "request", "->", "install", "(", "$", "link", "->", "getTarget", "(", ")", ",", "$", "link", "->", "getConstraint", "(", ")", ")", ";", "}", "$", "this", "->", "eventDispatcher", "->", "dispatchInstallerEvent", "(", "InstallerEvents", "::", "PRE_DEPENDENCIES_SOLVING", ",", "false", ",", "$", "policy", ",", "$", "pool", ",", "$", "installedRepo", ",", "$", "request", ")", ";", "$", "solver", "=", "new", "Solver", "(", "$", "policy", ",", "$", "pool", ",", "$", "installedRepo", ")", ";", "$", "ops", "=", "$", "solver", "->", "solve", "(", "$", "request", ",", "$", "this", "->", "ignorePlatformReqs", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatchInstallerEvent", "(", "InstallerEvents", "::", "POST_DEPENDENCIES_SOLVING", ",", "false", ",", "$", "policy", ",", "$", "pool", ",", "$", "installedRepo", ",", "$", "request", ",", "$", "ops", ")", ";", "foreach", "(", "$", "ops", "as", "$", "op", ")", "{", "if", "(", "$", "op", "->", "getJobType", "(", ")", "===", "'uninstall'", ")", "{", "$", "devPackages", "[", "]", "=", "$", "op", "->", "getPackage", "(", ")", ";", "}", "}", "}", "$", "platformReqs", "=", "$", "this", "->", "extractPlatformRequirements", "(", "$", "this", "->", "package", "->", "getRequires", "(", ")", ")", ";", "$", "platformDevReqs", "=", "$", "this", "->", "devMode", "?", "$", "this", "->", "extractPlatformRequirements", "(", "$", "this", "->", "package", "->", "getDevRequires", "(", ")", ")", ":", "array", "(", ")", ";", "$", "updatedLock", "=", "$", "this", "->", "locker", "->", "setLockData", "(", "array_diff", "(", "$", "localRepo", "->", "getCanonicalPackages", "(", ")", ",", "(", "array", ")", "$", "devPackages", ")", ",", "$", "devPackages", ",", "$", "platformReqs", ",", "$", "platformDevReqs", ",", "$", "aliases", ",", "$", "this", "->", "package", "->", "getMinimumStability", "(", ")", ",", "$", "this", "->", "package", "->", "getStabilityFlags", "(", ")", ",", "$", "this", "->", "preferStable", "||", "$", "this", "->", "package", "->", "getPreferStable", "(", ")", ",", "$", "this", "->", "preferLowest", ",", "$", "this", "->", "config", "->", "get", "(", "'platform'", ")", "?", ":", "array", "(", ")", ")", ";", "if", "(", "$", "updatedLock", ")", "{", "$", "this", "->", "io", "->", "writeError", "(", "'<info>Writing lock file</info>'", ")", ";", "}", "}", "if", "(", "$", "this", "->", "dumpAutoloader", ")", "{", "// write autoloader", "if", "(", "$", "this", "->", "optimizeAutoloader", ")", "{", "$", "this", "->", "io", "->", "writeError", "(", "'<info>Generating optimized autoload files</info>'", ")", ";", "}", "else", "{", "$", "this", "->", "io", "->", "writeError", "(", "'<info>Generating autoload files</info>'", ")", ";", "}", "$", "this", "->", "autoloadGenerator", "->", "setDevMode", "(", "$", "this", "->", "devMode", ")", ";", "$", "this", "->", "autoloadGenerator", "->", "dump", "(", "$", "this", "->", "config", ",", "$", "localRepo", ",", "$", "this", "->", "package", ",", "$", "this", "->", "installationManager", ",", "'composer'", ",", "$", "this", "->", "optimizeAutoloader", ")", ";", "}", "if", "(", "$", "this", "->", "runScripts", ")", "{", "// dispatch post event", "$", "eventName", "=", "$", "this", "->", "update", "?", "ScriptEvents", "::", "POST_UPDATE_CMD", ":", "ScriptEvents", "::", "POST_INSTALL_CMD", ";", "$", "this", "->", "eventDispatcher", "->", "dispatchScript", "(", "$", "eventName", ",", "$", "this", "->", "devMode", ")", ";", "}", "$", "vendorDir", "=", "$", "this", "->", "config", "->", "get", "(", "'vendor-dir'", ")", ";", "if", "(", "is_dir", "(", "$", "vendorDir", ")", ")", "{", "touch", "(", "$", "vendorDir", ")", ";", "}", "}", "return", "0", ";", "}" ]
Run installation (or update) @return int 0 on success or a positive error code on failure @throws \Exception
[ "Run", "installation", "(", "or", "update", ")" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Installer.php#L164-L352
mothership-ec/composer
src/Composer/Installer.php
Installer.movePluginsToFront
private function movePluginsToFront(array $operations) { $installerOps = array(); foreach ($operations as $idx => $op) { if ($op instanceof InstallOperation) { $package = $op->getPackage(); } elseif ($op instanceof UpdateOperation) { $package = $op->getTargetPackage(); } else { continue; } if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') { // ignore requirements to platform or composer-plugin-api $requires = array_keys($package->getRequires()); foreach ($requires as $index => $req) { if ($req === 'composer-plugin-api' || preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) { unset($requires[$index]); } } // if there are no other requirements, move the plugin to the top of the op list if (!count($requires)) { $installerOps[] = $op; unset($operations[$idx]); } } } return array_merge($installerOps, $operations); }
php
private function movePluginsToFront(array $operations) { $installerOps = array(); foreach ($operations as $idx => $op) { if ($op instanceof InstallOperation) { $package = $op->getPackage(); } elseif ($op instanceof UpdateOperation) { $package = $op->getTargetPackage(); } else { continue; } if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') { // ignore requirements to platform or composer-plugin-api $requires = array_keys($package->getRequires()); foreach ($requires as $index => $req) { if ($req === 'composer-plugin-api' || preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) { unset($requires[$index]); } } // if there are no other requirements, move the plugin to the top of the op list if (!count($requires)) { $installerOps[] = $op; unset($operations[$idx]); } } } return array_merge($installerOps, $operations); }
[ "private", "function", "movePluginsToFront", "(", "array", "$", "operations", ")", "{", "$", "installerOps", "=", "array", "(", ")", ";", "foreach", "(", "$", "operations", "as", "$", "idx", "=>", "$", "op", ")", "{", "if", "(", "$", "op", "instanceof", "InstallOperation", ")", "{", "$", "package", "=", "$", "op", "->", "getPackage", "(", ")", ";", "}", "elseif", "(", "$", "op", "instanceof", "UpdateOperation", ")", "{", "$", "package", "=", "$", "op", "->", "getTargetPackage", "(", ")", ";", "}", "else", "{", "continue", ";", "}", "if", "(", "$", "package", "->", "getType", "(", ")", "===", "'composer-plugin'", "||", "$", "package", "->", "getType", "(", ")", "===", "'composer-installer'", ")", "{", "// ignore requirements to platform or composer-plugin-api", "$", "requires", "=", "array_keys", "(", "$", "package", "->", "getRequires", "(", ")", ")", ";", "foreach", "(", "$", "requires", "as", "$", "index", "=>", "$", "req", ")", "{", "if", "(", "$", "req", "===", "'composer-plugin-api'", "||", "preg_match", "(", "PlatformRepository", "::", "PLATFORM_PACKAGE_REGEX", ",", "$", "req", ")", ")", "{", "unset", "(", "$", "requires", "[", "$", "index", "]", ")", ";", "}", "}", "// if there are no other requirements, move the plugin to the top of the op list", "if", "(", "!", "count", "(", "$", "requires", ")", ")", "{", "$", "installerOps", "[", "]", "=", "$", "op", ";", "unset", "(", "$", "operations", "[", "$", "idx", "]", ")", ";", "}", "}", "}", "return", "array_merge", "(", "$", "installerOps", ",", "$", "operations", ")", ";", "}" ]
Workaround: if your packages depend on plugins, we must be sure that those are installed / updated first; else it would lead to packages being installed multiple times in different folders, when running Composer twice. While this does not fix the root-causes of https://github.com/composer/composer/issues/1147, it at least fixes the symptoms and makes usage of composer possible (again) in such scenarios. @param OperationInterface[] $operations @return OperationInterface[] reordered operation list
[ "Workaround", ":", "if", "your", "packages", "depend", "on", "plugins", "we", "must", "be", "sure", "that", "those", "are", "installed", "/", "updated", "first", ";", "else", "it", "would", "lead", "to", "packages", "being", "installed", "multiple", "times", "in", "different", "folders", "when", "running", "Composer", "twice", "." ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Installer.php#L631-L660
jeffturcotte/jest
src/Jest/Injector.php
Injector.invoke
public function invoke(Callable $callable) { $reflection = $this->reflectCallable($callable); $args = []; foreach($reflection->getParameters() as $param) { $type = $param->getClass()->getName(); if (in_array($type, $this->resolving)) { throw new \LogicException("Recursive dependency: $type is currently instatiating."); } $args[] = ($param->allowsNull() && !isset($this[$type])) ? null : $this[$type]; } return call_user_func_array($callable, $args); }
php
public function invoke(Callable $callable) { $reflection = $this->reflectCallable($callable); $args = []; foreach($reflection->getParameters() as $param) { $type = $param->getClass()->getName(); if (in_array($type, $this->resolving)) { throw new \LogicException("Recursive dependency: $type is currently instatiating."); } $args[] = ($param->allowsNull() && !isset($this[$type])) ? null : $this[$type]; } return call_user_func_array($callable, $args); }
[ "public", "function", "invoke", "(", "Callable", "$", "callable", ")", "{", "$", "reflection", "=", "$", "this", "->", "reflectCallable", "(", "$", "callable", ")", ";", "$", "args", "=", "[", "]", ";", "foreach", "(", "$", "reflection", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "$", "type", "=", "$", "param", "->", "getClass", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "in_array", "(", "$", "type", ",", "$", "this", "->", "resolving", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Recursive dependency: $type is currently instatiating.\"", ")", ";", "}", "$", "args", "[", "]", "=", "(", "$", "param", "->", "allowsNull", "(", ")", "&&", "!", "isset", "(", "$", "this", "[", "$", "type", "]", ")", ")", "?", "null", ":", "$", "this", "[", "$", "type", "]", ";", "}", "return", "call_user_func_array", "(", "$", "callable", ",", "$", "args", ")", ";", "}" ]
Invoke a callable and injects dependencies @param $callable mixed The Closure or object to inject dependencies into @return mixed The value return from the callable
[ "Invoke", "a", "callable", "and", "injects", "dependencies" ]
train
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L55-L72
jeffturcotte/jest
src/Jest/Injector.php
Injector.offsetGet
public function offsetGet($class) { if (!isset($this->factories[$class]) && !isset($this->instances[$class])) { throw new \InvalidArgumentException("$class has not been defined"); } if (isset($this->instances[$class])) { return $this->instances[$class]; } array_push($this->resolving, $class); $object = $this->invoke($this->factories[$class]); array_pop($this->resolving); return $object; }
php
public function offsetGet($class) { if (!isset($this->factories[$class]) && !isset($this->instances[$class])) { throw new \InvalidArgumentException("$class has not been defined"); } if (isset($this->instances[$class])) { return $this->instances[$class]; } array_push($this->resolving, $class); $object = $this->invoke($this->factories[$class]); array_pop($this->resolving); return $object; }
[ "public", "function", "offsetGet", "(", "$", "class", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "factories", "[", "$", "class", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "instances", "[", "$", "class", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"$class has not been defined\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "instances", "[", "$", "class", "]", ")", ")", "{", "return", "$", "this", "->", "instances", "[", "$", "class", "]", ";", "}", "array_push", "(", "$", "this", "->", "resolving", ",", "$", "class", ")", ";", "$", "object", "=", "$", "this", "->", "invoke", "(", "$", "this", "->", "factories", "[", "$", "class", "]", ")", ";", "array_pop", "(", "$", "this", "->", "resolving", ")", ";", "return", "$", "object", ";", "}" ]
get a dependency for the supplied class @param $type string The type to get @return mixed The dependency/type value
[ "get", "a", "dependency", "for", "the", "supplied", "class" ]
train
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L110-L125
jeffturcotte/jest
src/Jest/Injector.php
Injector.offsetSet
public function offsetSet($class, $factory) { if (is_callable($factory)) { $this->factories[$class] = $factory; } else if (is_object($factory)) { $this->instances[$class] = $factory; } else { throw new \InvalidArgumentException("Dependency supplied is neither a callable or an object"); } }
php
public function offsetSet($class, $factory) { if (is_callable($factory)) { $this->factories[$class] = $factory; } else if (is_object($factory)) { $this->instances[$class] = $factory; } else { throw new \InvalidArgumentException("Dependency supplied is neither a callable or an object"); } }
[ "public", "function", "offsetSet", "(", "$", "class", ",", "$", "factory", ")", "{", "if", "(", "is_callable", "(", "$", "factory", ")", ")", "{", "$", "this", "->", "factories", "[", "$", "class", "]", "=", "$", "factory", ";", "}", "else", "if", "(", "is_object", "(", "$", "factory", ")", ")", "{", "$", "this", "->", "instances", "[", "$", "class", "]", "=", "$", "factory", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Dependency supplied is neither a callable or an object\"", ")", ";", "}", "}" ]
Registers a dependency for injection @throws \InvalidArgumentException @param $class string The class to register @param $factory mixed A callable or object The factory used to create the dependency or the instance of the dependency
[ "Registers", "a", "dependency", "for", "injection" ]
train
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L139-L148
jeffturcotte/jest
src/Jest/Injector.php
Injector.reflectCallable
protected function reflectCallable($callable) { if (is_string($callable) && strpos($callable, '::')) { $callable = explode('::', $callable, 2); } if (is_a($callable, 'Closure')) { $reflection = new \ReflectionFunction($callable); } else if (is_object($callable)) { $reflection = new \ReflectionMethod(get_class($callable), '__invoke'); } else if (is_array($callable) && count($callable) == 2) { $reflection = new \ReflectionMethod((is_object($callable[0]) ? get_class($callable[0]) : $callable[0]), $callable[1]); } else if (is_string($callable) && function_exists($callable)) { $reflection = new \ReflectionFunction($callable); } return $reflection; }
php
protected function reflectCallable($callable) { if (is_string($callable) && strpos($callable, '::')) { $callable = explode('::', $callable, 2); } if (is_a($callable, 'Closure')) { $reflection = new \ReflectionFunction($callable); } else if (is_object($callable)) { $reflection = new \ReflectionMethod(get_class($callable), '__invoke'); } else if (is_array($callable) && count($callable) == 2) { $reflection = new \ReflectionMethod((is_object($callable[0]) ? get_class($callable[0]) : $callable[0]), $callable[1]); } else if (is_string($callable) && function_exists($callable)) { $reflection = new \ReflectionFunction($callable); } return $reflection; }
[ "protected", "function", "reflectCallable", "(", "$", "callable", ")", "{", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "strpos", "(", "$", "callable", ",", "'::'", ")", ")", "{", "$", "callable", "=", "explode", "(", "'::'", ",", "$", "callable", ",", "2", ")", ";", "}", "if", "(", "is_a", "(", "$", "callable", ",", "'Closure'", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "callable", ")", ";", "}", "else", "if", "(", "is_object", "(", "$", "callable", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "get_class", "(", "$", "callable", ")", ",", "'__invoke'", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "callable", ")", "&&", "count", "(", "$", "callable", ")", "==", "2", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "(", "is_object", "(", "$", "callable", "[", "0", "]", ")", "?", "get_class", "(", "$", "callable", "[", "0", "]", ")", ":", "$", "callable", "[", "0", "]", ")", ",", "$", "callable", "[", "1", "]", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "function_exists", "(", "$", "callable", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "callable", ")", ";", "}", "return", "$", "reflection", ";", "}" ]
Reflect a callable @param $callable Callable The callable to reflect @return ReflectionFunction|ReflectionMethod
[ "Reflect", "a", "callable" ]
train
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L159-L176
InactiveProjects/limoncello-illuminate
app/Database/Seeds/Runner.php
Runner.run
public function run() { Model::unguard(); try { foreach ($this->seederClasses as $seederClass) { $this->parentSeeder->call($seederClass); } } finally { Model::reguard(); } }
php
public function run() { Model::unguard(); try { foreach ($this->seederClasses as $seederClass) { $this->parentSeeder->call($seederClass); } } finally { Model::reguard(); } }
[ "public", "function", "run", "(", ")", "{", "Model", "::", "unguard", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "seederClasses", "as", "$", "seederClass", ")", "{", "$", "this", "->", "parentSeeder", "->", "call", "(", "$", "seederClass", ")", ";", "}", "}", "finally", "{", "Model", "::", "reguard", "(", ")", ";", "}", "}" ]
Run seeders. @return void @SuppressWarnings(PHPMD.StaticAccess)
[ "Run", "seeders", "." ]
train
https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Seeds/Runner.php#L44-L54
interactivesolutions/honeycomb-core
src/http/controllers/traits/HCQueryMaking.php
HCQueryMaking.getRequestParameters
protected function getRequestParameters(Builder $query, array $availableFields) { $givenFields = $this->getRequestParametersRaw(); foreach ($givenFields as $fieldName => $value) { $from = substr($fieldName, 0, -5); $to = substr($fieldName, 0, -3); if (in_array($from, $availableFields) && $value != '') $query->where($from, '>=', $value); if (in_array($to, $availableFields) && $value != '') $query->where($to, '<=', $value); if (in_array($fieldName, $availableFields)) if (is_array($value)) $query->whereIn($fieldName, $value); else $query->where($fieldName, '=', $value); } return $query; }
php
protected function getRequestParameters(Builder $query, array $availableFields) { $givenFields = $this->getRequestParametersRaw(); foreach ($givenFields as $fieldName => $value) { $from = substr($fieldName, 0, -5); $to = substr($fieldName, 0, -3); if (in_array($from, $availableFields) && $value != '') $query->where($from, '>=', $value); if (in_array($to, $availableFields) && $value != '') $query->where($to, '<=', $value); if (in_array($fieldName, $availableFields)) if (is_array($value)) $query->whereIn($fieldName, $value); else $query->where($fieldName, '=', $value); } return $query; }
[ "protected", "function", "getRequestParameters", "(", "Builder", "$", "query", ",", "array", "$", "availableFields", ")", "{", "$", "givenFields", "=", "$", "this", "->", "getRequestParametersRaw", "(", ")", ";", "foreach", "(", "$", "givenFields", "as", "$", "fieldName", "=>", "$", "value", ")", "{", "$", "from", "=", "substr", "(", "$", "fieldName", ",", "0", ",", "-", "5", ")", ";", "$", "to", "=", "substr", "(", "$", "fieldName", ",", "0", ",", "-", "3", ")", ";", "if", "(", "in_array", "(", "$", "from", ",", "$", "availableFields", ")", "&&", "$", "value", "!=", "''", ")", "$", "query", "->", "where", "(", "$", "from", ",", "'>='", ",", "$", "value", ")", ";", "if", "(", "in_array", "(", "$", "to", ",", "$", "availableFields", ")", "&&", "$", "value", "!=", "''", ")", "$", "query", "->", "where", "(", "$", "to", ",", "'<='", ",", "$", "value", ")", ";", "if", "(", "in_array", "(", "$", "fieldName", ",", "$", "availableFields", ")", ")", "if", "(", "is_array", "(", "$", "value", ")", ")", "$", "query", "->", "whereIn", "(", "$", "fieldName", ",", "$", "value", ")", ";", "else", "$", "query", "->", "where", "(", "$", "fieldName", ",", "'='", ",", "$", "value", ")", ";", "}", "return", "$", "query", ";", "}" ]
Get only valid request params for records filtering @param Builder $query @param array $availableFields - Model available fields to select @return mixed
[ "Get", "only", "valid", "request", "params", "for", "records", "filtering" ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/traits/HCQueryMaking.php#L40-L63
interactivesolutions/honeycomb-core
src/http/controllers/traits/HCQueryMaking.php
HCQueryMaking.getStrictRequestParameters
protected function getStrictRequestParameters() { $data = []; foreach ($this->strictUpdateKeys as $value) if (request()->has($value)) $data[$value] = request($value); return $data; }
php
protected function getStrictRequestParameters() { $data = []; foreach ($this->strictUpdateKeys as $value) if (request()->has($value)) $data[$value] = request($value); return $data; }
[ "protected", "function", "getStrictRequestParameters", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "strictUpdateKeys", "as", "$", "value", ")", "if", "(", "request", "(", ")", "->", "has", "(", "$", "value", ")", ")", "$", "data", "[", "$", "value", "]", "=", "request", "(", "$", "value", ")", ";", "return", "$", "data", ";", "}" ]
Gathering all allowed request parameters for strict update @return array
[ "Gathering", "all", "allowed", "request", "parameters", "for", "strict", "update" ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/traits/HCQueryMaking.php#L80-L89
interactivesolutions/honeycomb-core
src/http/controllers/traits/HCQueryMaking.php
HCQueryMaking.orderData
protected function orderData(Builder $query, array $availableFields) { $sortBy = request()->input('sort_by'); $sortOrder = request()->input('sort_order'); if (in_array($sortBy, $availableFields)) if (in_array(strtolower($sortOrder), ['asc', 'desc'])) return $query->orderBy($sortBy, $sortOrder); return $query->orderBy('created_at', 'desc'); }
php
protected function orderData(Builder $query, array $availableFields) { $sortBy = request()->input('sort_by'); $sortOrder = request()->input('sort_order'); if (in_array($sortBy, $availableFields)) if (in_array(strtolower($sortOrder), ['asc', 'desc'])) return $query->orderBy($sortBy, $sortOrder); return $query->orderBy('created_at', 'desc'); }
[ "protected", "function", "orderData", "(", "Builder", "$", "query", ",", "array", "$", "availableFields", ")", "{", "$", "sortBy", "=", "request", "(", ")", "->", "input", "(", "'sort_by'", ")", ";", "$", "sortOrder", "=", "request", "(", ")", "->", "input", "(", "'sort_order'", ")", ";", "if", "(", "in_array", "(", "$", "sortBy", ",", "$", "availableFields", ")", ")", "if", "(", "in_array", "(", "strtolower", "(", "$", "sortOrder", ")", ",", "[", "'asc'", ",", "'desc'", "]", ")", ")", "return", "$", "query", "->", "orderBy", "(", "$", "sortBy", ",", "$", "sortOrder", ")", ";", "return", "$", "query", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", ";", "}" ]
Ordering content @param Builder $query @param array $availableFields @return mixed
[ "Ordering", "content" ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/traits/HCQueryMaking.php#L98-L108
interactivesolutions/honeycomb-core
src/http/controllers/traits/HCQueryMaking.php
HCQueryMaking.search
protected function search(Builder $query) { $q = request('q'); if (!$q || strlen($q) < $this->minimumSearchInputLength) return $query; return $this->searchQuery($query, $q); }
php
protected function search(Builder $query) { $q = request('q'); if (!$q || strlen($q) < $this->minimumSearchInputLength) return $query; return $this->searchQuery($query, $q); }
[ "protected", "function", "search", "(", "Builder", "$", "query", ")", "{", "$", "q", "=", "request", "(", "'q'", ")", ";", "if", "(", "!", "$", "q", "||", "strlen", "(", "$", "q", ")", "<", "$", "this", "->", "minimumSearchInputLength", ")", "return", "$", "query", ";", "return", "$", "this", "->", "searchQuery", "(", "$", "query", ",", "$", "q", ")", ";", "}" ]
Creating data list based on search @param Builder $query @return mixed
[ "Creating", "data", "list", "based", "on", "search" ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/traits/HCQueryMaking.php#L116-L124
interactivesolutions/honeycomb-core
src/http/controllers/traits/HCQueryMaking.php
HCQueryMaking.checkForDeleted
protected function checkForDeleted(Builder $query) { if (request()->has('deleted') && request()->input('deleted') === '1') $query = $query->onlyTrashed(); return $query; }
php
protected function checkForDeleted(Builder $query) { if (request()->has('deleted') && request()->input('deleted') === '1') $query = $query->onlyTrashed(); return $query; }
[ "protected", "function", "checkForDeleted", "(", "Builder", "$", "query", ")", "{", "if", "(", "request", "(", ")", "->", "has", "(", "'deleted'", ")", "&&", "request", "(", ")", "->", "input", "(", "'deleted'", ")", "===", "'1'", ")", "$", "query", "=", "$", "query", "->", "onlyTrashed", "(", ")", ";", "return", "$", "query", ";", "}" ]
Check for deleted records option @param Builder $query @return mixed
[ "Check", "for", "deleted", "records", "option" ]
train
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/traits/HCQueryMaking.php#L140-L146
gregoryv/php-logger
src/Logger.php
Logger.turn
public function turn($toggle) { if(preg_match_all('/^(on|off) (all)?\s?(debug|info|notice|warn|error|critical|alert|emergency)$/', $toggle, $matches)) { $flag = $matches[1][0]; $all = $matches[2][0]; $name = $matches[3][0]; $this->sieve->toggle($flag, $name); if($all === 'all') { self::$SIEVE->toggle($flag, $name); } } else { throw new \InvalidArgumentException("Invalid format: $toggle"); } }
php
public function turn($toggle) { if(preg_match_all('/^(on|off) (all)?\s?(debug|info|notice|warn|error|critical|alert|emergency)$/', $toggle, $matches)) { $flag = $matches[1][0]; $all = $matches[2][0]; $name = $matches[3][0]; $this->sieve->toggle($flag, $name); if($all === 'all') { self::$SIEVE->toggle($flag, $name); } } else { throw new \InvalidArgumentException("Invalid format: $toggle"); } }
[ "public", "function", "turn", "(", "$", "toggle", ")", "{", "if", "(", "preg_match_all", "(", "'/^(on|off) (all)?\\s?(debug|info|notice|warn|error|critical|alert|emergency)$/'", ",", "$", "toggle", ",", "$", "matches", ")", ")", "{", "$", "flag", "=", "$", "matches", "[", "1", "]", "[", "0", "]", ";", "$", "all", "=", "$", "matches", "[", "2", "]", "[", "0", "]", ";", "$", "name", "=", "$", "matches", "[", "3", "]", "[", "0", "]", ";", "$", "this", "->", "sieve", "->", "toggle", "(", "$", "flag", ",", "$", "name", ")", ";", "if", "(", "$", "all", "===", "'all'", ")", "{", "self", "::", "$", "SIEVE", "->", "toggle", "(", "$", "flag", ",", "$", "name", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid format: $toggle\"", ")", ";", "}", "}" ]
Sets logging state of the given severity level in a readable format @example $log->turn('on debug'); @example $log->turn('off all warn'); @param string $toggle format: (on|off) [all] (debug|info|notice|warn|error|critical|alert|emergency)
[ "Sets", "logging", "state", "of", "the", "given", "severity", "level", "in", "a", "readable", "format" ]
train
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L68-L81
gregoryv/php-logger
src/Logger.php
Logger.debug
public function debug($value='') { if($this->sieve->debug) { self::$writer->swrite(LOG_DEBUG, sprintf($this->template, 'DEBUG', $value)); } }
php
public function debug($value='') { if($this->sieve->debug) { self::$writer->swrite(LOG_DEBUG, sprintf($this->template, 'DEBUG', $value)); } }
[ "public", "function", "debug", "(", "$", "value", "=", "''", ")", "{", "if", "(", "$", "this", "->", "sieve", "->", "debug", ")", "{", "self", "::", "$", "writer", "->", "swrite", "(", "LOG_DEBUG", ",", "sprintf", "(", "$", "this", "->", "template", ",", "'DEBUG'", ",", "$", "value", ")", ")", ";", "}", "}" ]
Debug (severity 7): debug-level messages
[ "Debug", "(", "severity", "7", ")", ":", "debug", "-", "level", "messages" ]
train
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L87-L92
gregoryv/php-logger
src/Logger.php
Logger.debugf
public function debugf() { $args = func_get_args(); $format = array_shift($args); $this->debug(vsprintf($format, $args)); }
php
public function debugf() { $args = func_get_args(); $format = array_shift($args); $this->debug(vsprintf($format, $args)); }
[ "public", "function", "debugf", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "format", "=", "array_shift", "(", "$", "args", ")", ";", "$", "this", "->", "debug", "(", "vsprintf", "(", "$", "format", ",", "$", "args", ")", ")", ";", "}" ]
Same as debug(sprintf($format, $args...))
[ "Same", "as", "debug", "(", "sprintf", "(", "$format", "$args", "...", "))" ]
train
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L97-L102
gregoryv/php-logger
src/Logger.php
Logger.info
public function info($value='') { if($this->sieve->info) { self::$writer->swrite(LOG_INFO, sprintf($this->template, 'INFO', $value)); } }
php
public function info($value='') { if($this->sieve->info) { self::$writer->swrite(LOG_INFO, sprintf($this->template, 'INFO', $value)); } }
[ "public", "function", "info", "(", "$", "value", "=", "''", ")", "{", "if", "(", "$", "this", "->", "sieve", "->", "info", ")", "{", "self", "::", "$", "writer", "->", "swrite", "(", "LOG_INFO", ",", "sprintf", "(", "$", "this", "->", "template", ",", "'INFO'", ",", "$", "value", ")", ")", ";", "}", "}" ]
Informational (severity 6): informational messages
[ "Informational", "(", "severity", "6", ")", ":", "informational", "messages" ]
train
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L107-L112