repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Galbar/JsonPath-PHP | src/Galbar/Utilities/ArraySlice.php | ArraySlice.slice | public static function slice(&$array, $start = null, $stop = null, $step = null, $byReference = false)
{
$result = array();
$indexes = self::sliceIndices(count($array), $start, $stop, $step);
if ($byReference) {
foreach ($indexes as $i) {
$result[] = &$array[$i];
... | php | public static function slice(&$array, $start = null, $stop = null, $step = null, $byReference = false)
{
$result = array();
$indexes = self::sliceIndices(count($array), $start, $stop, $step);
if ($byReference) {
foreach ($indexes as $i) {
$result[] = &$array[$i];
... | [
"public",
"static",
"function",
"slice",
"(",
"&",
"$",
"array",
",",
"$",
"start",
"=",
"null",
",",
"$",
"stop",
"=",
"null",
",",
"$",
"step",
"=",
"null",
",",
"$",
"byReference",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",... | Implements the Python slice behaviour
* a[1:2:3] => slice($a, 1, 2, 3)
* a[1:4] => slice($a, 1, 4)
* a[3::2] => slice($a, 3, null, 2)
If $byReference is true, then the elements of
the resulting array will be references to the initial
array.
@param array $array array
@param int|null $start start
@param int|null $s... | [
"Implements",
"the",
"Python",
"slice",
"behaviour"
] | train | https://github.com/Galbar/JsonPath-PHP/blob/ea104b4f835388018f4bd529a2dace88617d5be6/src/Galbar/Utilities/ArraySlice.php#L41-L55 |
Galbar/JsonPath-PHP | src/Galbar/JsonPath/JsonObject.php | JsonObject.get | public function get($jsonPath)
{
$this->hasDiverged = false;
$result = $this->getReal($this->jsonObject, $jsonPath);
if ($this->smartGet && $result !== false && !$this->hasDiverged) {
return $result[0];
}
return $result;
} | php | public function get($jsonPath)
{
$this->hasDiverged = false;
$result = $this->getReal($this->jsonObject, $jsonPath);
if ($this->smartGet && $result !== false && !$this->hasDiverged) {
return $result[0];
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"jsonPath",
")",
"{",
"$",
"this",
"->",
"hasDiverged",
"=",
"false",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getReal",
"(",
"$",
"this",
"->",
"jsonObject",
",",
"$",
"jsonPath",
")",
";",
"if",
"(",
"$"... | Returns an array containing references to the
objects that match the JsonPath. If the result is
empty returns false.
If smartGet was set to true when creating the instance and
the JsonPath given does not branch, it will return the value
instead of an array of one element.
@param string $jsonPath jsonPath
@return mix... | [
"Returns",
"an",
"array",
"containing",
"references",
"to",
"the",
"objects",
"that",
"match",
"the",
"JsonPath",
".",
"If",
"the",
"result",
"is",
"empty",
"returns",
"false",
"."
] | train | https://github.com/Galbar/JsonPath-PHP/blob/ea104b4f835388018f4bd529a2dace88617d5be6/src/Galbar/JsonPath/JsonObject.php#L267-L275 |
Galbar/JsonPath-PHP | src/Galbar/JsonPath/JsonObject.php | JsonObject.getJsonObjects | public function getJsonObjects($jsonPath)
{
$this->hasDiverged = false;
$result = $this->getReal($this->jsonObject, $jsonPath);
if ($result !== false) {
$objs = array();
foreach($result as &$value) {
$jsonObject = new JsonObject(null, $this->smartGet);... | php | public function getJsonObjects($jsonPath)
{
$this->hasDiverged = false;
$result = $this->getReal($this->jsonObject, $jsonPath);
if ($result !== false) {
$objs = array();
foreach($result as &$value) {
$jsonObject = new JsonObject(null, $this->smartGet);... | [
"public",
"function",
"getJsonObjects",
"(",
"$",
"jsonPath",
")",
"{",
"$",
"this",
"->",
"hasDiverged",
"=",
"false",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getReal",
"(",
"$",
"this",
"->",
"jsonObject",
",",
"$",
"jsonPath",
")",
";",
"if",
... | Return an array of new JsonObjects representing the results of the
given JsonPath. These objects contain references to the elements in the
original JsonObject.
This is affected by smartGet the same way JsonObject::get is affected
This can cause JsonObject to have actual values (not object/array) as root.
This is usef... | [
"Return",
"an",
"array",
"of",
"new",
"JsonObjects",
"representing",
"the",
"results",
"of",
"the",
"given",
"JsonPath",
".",
"These",
"objects",
"contain",
"references",
"to",
"the",
"elements",
"in",
"the",
"original",
"JsonObject",
"."
] | train | https://github.com/Galbar/JsonPath-PHP/blob/ea104b4f835388018f4bd529a2dace88617d5be6/src/Galbar/JsonPath/JsonObject.php#L293-L310 |
Galbar/JsonPath-PHP | src/Galbar/JsonPath/JsonObject.php | JsonObject.set | public function set($jsonPath, $value)
{
$result = $this->getReal($this->jsonObject, $jsonPath, true);
if ($result !== false) {
foreach ($result as &$element) {
$element = $value;
}
}
return $this;
} | php | public function set($jsonPath, $value)
{
$result = $this->getReal($this->jsonObject, $jsonPath, true);
if ($result !== false) {
foreach ($result as &$element) {
$element = $value;
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"jsonPath",
",",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getReal",
"(",
"$",
"this",
"->",
"jsonObject",
",",
"$",
"jsonPath",
",",
"true",
")",
";",
"if",
"(",
"$",
"result",
"!==",
... | Sets all elements that result from the $jsonPath query
to $value. This method will create previously non-existent
JSON objects if the path contains them (p.e. if quering '$.a'
results in false, when setting '$.a.b' to a value '$.a' will be created
as a result of this).
This method returns $this to enable fluent
interf... | [
"Sets",
"all",
"elements",
"that",
"result",
"from",
"the",
"$jsonPath",
"query",
"to",
"$value",
".",
"This",
"method",
"will",
"create",
"previously",
"non",
"-",
"existent",
"JSON",
"objects",
"if",
"the",
"path",
"contains",
"them",
"(",
"p",
".",
"e",... | train | https://github.com/Galbar/JsonPath-PHP/blob/ea104b4f835388018f4bd529a2dace88617d5be6/src/Galbar/JsonPath/JsonObject.php#L328-L337 |
Galbar/JsonPath-PHP | src/Galbar/JsonPath/JsonObject.php | JsonObject.add | public function add($jsonPath, $value, $field=null)
{
$result = $this->getReal($this->jsonObject, $jsonPath, true);
foreach ($result as &$element) {
if (is_array($element)) {
if ($field == null) {
$element[] = $value;
}
... | php | public function add($jsonPath, $value, $field=null)
{
$result = $this->getReal($this->jsonObject, $jsonPath, true);
foreach ($result as &$element) {
if (is_array($element)) {
if ($field == null) {
$element[] = $value;
}
... | [
"public",
"function",
"add",
"(",
"$",
"jsonPath",
",",
"$",
"value",
",",
"$",
"field",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getReal",
"(",
"$",
"this",
"->",
"jsonObject",
",",
"$",
"jsonPath",
",",
"true",
")",
";",
"... | Append a new value to all json objects/arrays that match
the $jsonPath path. If $field is not null, the new value
will be added with $field as key (this will transform
json arrays into objects). This method returns $this to
enable fluent interface.
@param string $jsonPath jsonPath
@param mixed $value value
@param stri... | [
"Append",
"a",
"new",
"value",
"to",
"all",
"json",
"objects",
"/",
"arrays",
"that",
"match",
"the",
"$jsonPath",
"path",
".",
"If",
"$field",
"is",
"not",
"null",
"the",
"new",
"value",
"will",
"be",
"added",
"with",
"$field",
"as",
"key",
"(",
"this... | train | https://github.com/Galbar/JsonPath-PHP/blob/ea104b4f835388018f4bd529a2dace88617d5be6/src/Galbar/JsonPath/JsonObject.php#L352-L366 |
Galbar/JsonPath-PHP | src/Galbar/JsonPath/JsonObject.php | JsonObject.remove | public function remove($jsonPath, $field)
{
$result = $this->getReal($this->jsonObject, $jsonPath);
foreach ($result as &$element) {
if (is_array($element)) {
unset($element[$field]);
}
}
return $this;
} | php | public function remove($jsonPath, $field)
{
$result = $this->getReal($this->jsonObject, $jsonPath);
foreach ($result as &$element) {
if (is_array($element)) {
unset($element[$field]);
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"jsonPath",
",",
"$",
"field",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getReal",
"(",
"$",
"this",
"->",
"jsonObject",
",",
"$",
"jsonPath",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"&",
"$"... | Remove $field from json objects/arrays that match
$jsonPath path. This method returns $this to enable
fluent interface.
@param mixed $jsonPath jsonPath
@param mixed $field field
@return JsonObject | [
"Remove",
"$field",
"from",
"json",
"objects",
"/",
"arrays",
"that",
"match",
"$jsonPath",
"path",
".",
"This",
"method",
"returns",
"$this",
"to",
"enable",
"fluent",
"interface",
"."
] | train | https://github.com/Galbar/JsonPath-PHP/blob/ea104b4f835388018f4bd529a2dace88617d5be6/src/Galbar/JsonPath/JsonObject.php#L378-L387 |
asvae/laravel-api-tester | src/Storages/JsonStorage.php | JsonStorage.get | public function get()
{
$fullPath = $this->getFilePath();
if ($this->files->exists($fullPath)) {
$content = $this->files->get($fullPath);
return $this->makeCollection($this->parseResult($content));
}
return $this->makeCollection();
} | php | public function get()
{
$fullPath = $this->getFilePath();
if ($this->files->exists($fullPath)) {
$content = $this->files->get($fullPath);
return $this->makeCollection($this->parseResult($content));
}
return $this->makeCollection();
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"fullPath",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"fullPath",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",... | Return array parsed from file content.
@return RequestCollection | [
"Return",
"array",
"parsed",
"from",
"file",
"content",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/JsonStorage.php#L93-L105 |
asvae/laravel-api-tester | src/Storages/JsonStorage.php | JsonStorage.createDirectoryIfNotExists | protected function createDirectoryIfNotExists()
{
if (!is_dir($this->getPath())) {
$this->files->makeDirectory($this->getPath(), 0755, true);
}
} | php | protected function createDirectoryIfNotExists()
{
if (!is_dir($this->getPath())) {
$this->files->makeDirectory($this->getPath(), 0755, true);
}
} | [
"protected",
"function",
"createDirectoryIfNotExists",
"(",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"makeDirectory",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
... | Make directory path if not exists | [
"Make",
"directory",
"path",
"if",
"not",
"exists"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/JsonStorage.php#L123-L128 |
asvae/laravel-api-tester | src/Storages/JsonStorage.php | JsonStorage.parseResult | protected function parseResult($content)
{
$data = [];
foreach (explode(static::ROW_DELIMITER, $content) as $row) {
if (empty($row)) {
continue;
}
$data[] = json_decode($row, true);
}
return $data;
} | php | protected function parseResult($content)
{
$data = [];
foreach (explode(static::ROW_DELIMITER, $content) as $row) {
if (empty($row)) {
continue;
}
$data[] = json_decode($row, true);
}
return $data;
} | [
"protected",
"function",
"parseResult",
"(",
"$",
"content",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"static",
"::",
"ROW_DELIMITER",
",",
"$",
"content",
")",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"empty",
"(",
... | Parse result form given string
@param $content
@return array | [
"Parse",
"result",
"form",
"given",
"string"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/JsonStorage.php#L137-L150 |
asvae/laravel-api-tester | src/Storages/JsonStorage.php | JsonStorage.prepareContent | private function prepareContent($data)
{
$content = '';
foreach ($data as $row) {
$content .= $this->convertToJson($row) . static::ROW_DELIMITER;
}
return $content;
} | php | private function prepareContent($data)
{
$content = '';
foreach ($data as $row) {
$content .= $this->convertToJson($row) . static::ROW_DELIMITER;
}
return $content;
} | [
"private",
"function",
"prepareContent",
"(",
"$",
"data",
")",
"{",
"$",
"content",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
"{",
"$",
"content",
".=",
"$",
"this",
"->",
"convertToJson",
"(",
"$",
"row",
")",
".",
"stat... | Prepare content string from given data
@param \Traversable|array $data
@return string | [
"Prepare",
"content",
"string",
"from",
"given",
"data"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/JsonStorage.php#L159-L168 |
asvae/laravel-api-tester | src/Storages/JsonStorage.php | JsonStorage.convertToJson | private function convertToJson($data)
{
if (is_array($data)) {
return json_encode($data);
}
if ($data instanceof Jsonable) {
return $data->toJson();
}
if ($data instanceof Arrayable) {
return json_encode($data->toArray());
}
... | php | private function convertToJson($data)
{
if (is_array($data)) {
return json_encode($data);
}
if ($data instanceof Jsonable) {
return $data->toJson();
}
if ($data instanceof Arrayable) {
return json_encode($data->toArray());
}
... | [
"private",
"function",
"convertToJson",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"$",
"data",
"instanceof",
"Jsonable",
")",
"{",
"return"... | @param $data
@return null|string | [
"@param",
"$data"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/JsonStorage.php#L175-L190 |
asvae/laravel-api-tester | src/Repositories/RouteDingoRepository.php | RouteDingoRepository.get | public function get($match = [], $except = [])
{
return $this->routes->filterMatch($match)
->filterExcept($except)
->values();
} | php | public function get($match = [], $except = [])
{
return $this->routes->filterMatch($match)
->filterExcept($except)
->values();
} | [
"public",
"function",
"get",
"(",
"$",
"match",
"=",
"[",
"]",
",",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"routes",
"->",
"filterMatch",
"(",
"$",
"match",
")",
"->",
"filterExcept",
"(",
"$",
"except",
")",
"->",
"... | @param array $match
@param array $except
@return \Asvae\ApiTester\Collections\RouteCollection | [
"@param",
"array",
"$match",
"@param",
"array",
"$except"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Repositories/RouteDingoRepository.php#L54-L59 |
asvae/laravel-api-tester | src/Providers/StorageServiceProvide.php | StorageServiceProvide.register | public function register()
{
// Регистрируем конкретный сторэйдж из списка доступных.
$this->app->singleton(StorageInterface::class, function (Container $app) {
// Defined driver
$selectedDriver = config('api-tester.storage_driver');
$driverClassName = config('api... | php | public function register()
{
// Регистрируем конкретный сторэйдж из списка доступных.
$this->app->singleton(StorageInterface::class, function (Container $app) {
// Defined driver
$selectedDriver = config('api-tester.storage_driver');
$driverClassName = config('api... | [
"public",
"function",
"register",
"(",
")",
"{",
"// Регистрируем конкретный сторэйдж из списка доступных.",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"StorageInterface",
"::",
"class",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"// Defined dri... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Providers/StorageServiceProvide.php#L37-L77 |
asvae/laravel-api-tester | src/Entities/RouteInfo.php | RouteInfo.getMethods | private function getMethods()
{
// Laravel <5.4
if (method_exists($this->route, 'getMethods')) {
return $this->route->getMethods();
}
// Laravel 5.4+
return $this->route->methods();
} | php | private function getMethods()
{
// Laravel <5.4
if (method_exists($this->route, 'getMethods')) {
return $this->route->getMethods();
}
// Laravel 5.4+
return $this->route->methods();
} | [
"private",
"function",
"getMethods",
"(",
")",
"{",
"// Laravel <5.4",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"route",
",",
"'getMethods'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"route",
"->",
"getMethods",
"(",
")",
";",
"}",
"// Lara... | Cross version get methods.
@return array | [
"Cross",
"version",
"get",
"methods",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Entities/RouteInfo.php#L78-L86 |
asvae/laravel-api-tester | src/Entities/RouteInfo.php | RouteInfo.getUri | protected function getUri(){
if (method_exists($this->route, 'getPath')){
// Laravel <5.4
return $this->route->getPath();
}
// Laravel 5.4+
return $this->route->uri();
} | php | protected function getUri(){
if (method_exists($this->route, 'getPath')){
// Laravel <5.4
return $this->route->getPath();
}
// Laravel 5.4+
return $this->route->uri();
} | [
"protected",
"function",
"getUri",
"(",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"route",
",",
"'getPath'",
")",
")",
"{",
"// Laravel <5.4",
"return",
"$",
"this",
"->",
"route",
"->",
"getPath",
"(",
")",
";",
"}",
"// Laravel 5.4+... | Backwards compatible uri getter.
@return string | [
"Backwards",
"compatible",
"uri",
"getter",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Entities/RouteInfo.php#L235-L243 |
asvae/laravel-api-tester | src/Entities/BaseEntity.php | BaseEntity.fill | public function fill(array $data)
{
$this->attributes = array_merge($this->attributes, $this->filterFillable($data));
} | php | public function fill(array $data)
{
$this->attributes = array_merge($this->attributes, $this->filterFillable($data));
} | [
"public",
"function",
"fill",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"filterFillable",
"(",
"$",
"data",
")",
")",
";",
"}"
] | Fill attributes that can be filled.
@param $data
@return void | [
"Fill",
"attributes",
"that",
"can",
"be",
"filled",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Entities/BaseEntity.php#L49-L52 |
asvae/laravel-api-tester | src/Collections/RouteCollection.php | RouteCollection.filterMatch | public function filterMatch($patterns)
{
$patterns = is_string($patterns) ? [$patterns] : $patterns;
// String pattern is assumed to be path.
foreach ($patterns as $key => $pattern) {
if (is_string($pattern)) {
$patterns[$key] = ['path' => $pattern];
... | php | public function filterMatch($patterns)
{
$patterns = is_string($patterns) ? [$patterns] : $patterns;
// String pattern is assumed to be path.
foreach ($patterns as $key => $pattern) {
if (is_string($pattern)) {
$patterns[$key] = ['path' => $pattern];
... | [
"public",
"function",
"filterMatch",
"(",
"$",
"patterns",
")",
"{",
"$",
"patterns",
"=",
"is_string",
"(",
"$",
"patterns",
")",
"?",
"[",
"$",
"patterns",
"]",
":",
"$",
"patterns",
";",
"// String pattern is assumed to be path.",
"foreach",
"(",
"$",
"pa... | Include routes that match patterns.
@param array <array|string> $patterns
@return static | [
"Include",
"routes",
"that",
"match",
"patterns",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Collections/RouteCollection.php#L21-L43 |
asvae/laravel-api-tester | src/Collections/RouteCollection.php | RouteCollection.filterExcept | public function filterExcept($patterns = [])
{
if (empty($patterns)) {
return $this;
}
$toExclude = $this->filterMatch($patterns)->keys()->toArray();
return $this->except($toExclude);
} | php | public function filterExcept($patterns = [])
{
if (empty($patterns)) {
return $this;
}
$toExclude = $this->filterMatch($patterns)->keys()->toArray();
return $this->except($toExclude);
} | [
"public",
"function",
"filterExcept",
"(",
"$",
"patterns",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"patterns",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"toExclude",
"=",
"$",
"this",
"->",
"filterMatch",
"(",
"$",
"patte... | Exclude routes that match patterns.
@param array <array|string> $patterns
@return static | [
"Exclude",
"routes",
"that",
"match",
"patterns",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Collections/RouteCollection.php#L53-L62 |
asvae/laravel-api-tester | src/Entities/RequestEntity.php | RequestEntity.createExisting | public static function createExisting($data)
{
$newRequest = new static($data);
$newRequest->setId($data['id']);
$newRequest->setExists(true);
return $newRequest;
} | php | public static function createExisting($data)
{
$newRequest = new static($data);
$newRequest->setId($data['id']);
$newRequest->setExists(true);
return $newRequest;
} | [
"public",
"static",
"function",
"createExisting",
"(",
"$",
"data",
")",
"{",
"$",
"newRequest",
"=",
"new",
"static",
"(",
"$",
"data",
")",
";",
"$",
"newRequest",
"->",
"setId",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"$",
"newRequest",
"->"... | @param $data
@return static | [
"@param",
"$data"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Entities/RequestEntity.php#L59-L66 |
asvae/laravel-api-tester | src/Repositories/RequestRepository.php | RequestRepository.persist | public function persist(RequestEntity $request)
{
$request->setId(str_random());
$this->requests->insert($request);
} | php | public function persist(RequestEntity $request)
{
$request->setId(str_random());
$this->requests->insert($request);
} | [
"public",
"function",
"persist",
"(",
"RequestEntity",
"$",
"request",
")",
"{",
"$",
"request",
"->",
"setId",
"(",
"str_random",
"(",
")",
")",
";",
"$",
"this",
"->",
"requests",
"->",
"insert",
"(",
"$",
"request",
")",
";",
"}"
] | @param \Asvae\ApiTester\Entities\RequestEntity $request
@return mixed | [
"@param",
"\\",
"Asvae",
"\\",
"ApiTester",
"\\",
"Entities",
"\\",
"RequestEntity",
"$request"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Repositories/RequestRepository.php#L83-L87 |
asvae/laravel-api-tester | src/Providers/RepositoryServiceProvider.php | RepositoryServiceProvider.register | public function register()
{
$this->app->singleton(RouteRepositoryInterface::class, function (Container $app) {
$repositories = [];
foreach (config('api-tester.route_repositories') as $repository) {
$repositories[] = $app->make($repository);
}
... | php | public function register()
{
$this->app->singleton(RouteRepositoryInterface::class, function (Container $app) {
$repositories = [];
foreach (config('api-tester.route_repositories') as $repository) {
$repositories[] = $app->make($repository);
}
... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"RouteRepositoryInterface",
"::",
"class",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"repositories",
"=",
"[",
"]",
";",
"foreach",
"("... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Providers/RepositoryServiceProvider.php#L29-L46 |
asvae/laravel-api-tester | src/Collections/RequestCollection.php | RequestCollection.load | public function load($data)
{
foreach ($data as $row) {
$this->put($row['id'], RequestEntity::createExisting($row));
}
return $this;
} | php | public function load($data)
{
foreach ($data as $row) {
$this->put($row['id'], RequestEntity::createExisting($row));
}
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"put",
"(",
"$",
"row",
"[",
"'id'",
"]",
",",
"RequestEntity",
"::",
"createExisting",
"(",
"$",
"row",
")",
")... | Load data to collection.
@param $data
@return static | [
"Load",
"data",
"to",
"collection",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Collections/RequestCollection.php#L48-L55 |
asvae/laravel-api-tester | src/Collections/RequestCollection.php | RequestCollection.onlyDiff | public function onlyDiff()
{
return $this->filter(function (RequestEntity $request) {
return ($request->notExists() || $request->isDirty()) && $request->notMarkedToDelete();
});
} | php | public function onlyDiff()
{
return $this->filter(function (RequestEntity $request) {
return ($request->notExists() || $request->isDirty()) && $request->notMarkedToDelete();
});
} | [
"public",
"function",
"onlyDiff",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"RequestEntity",
"$",
"request",
")",
"{",
"return",
"(",
"$",
"request",
"->",
"notExists",
"(",
")",
"||",
"$",
"request",
"->",
"isDirty",
... | Новые записи или измененные записи, которые не были помечены на удаление.
@return static | [
"Новые",
"записи",
"или",
"измененные",
"записи",
"которые",
"не",
"были",
"помечены",
"на",
"удаление",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Collections/RequestCollection.php#L69-L74 |
asvae/laravel-api-tester | src/Storages/FireBaseStorage.php | FireBaseStorage.get | public function get()
{
$result = $this->getFromFireBase();
$data = $this->addHeadersIfEmpty($result);
return $this->makeCollection($data);
} | php | public function get()
{
$result = $this->getFromFireBase();
$data = $this->addHeadersIfEmpty($result);
return $this->makeCollection($data);
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getFromFireBase",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"addHeadersIfEmpty",
"(",
"$",
"result",
")",
";",
"return",
"$",
"this",
"->",
"makeCollection",
... | Get data from resource.
@return RequestCollection | [
"Get",
"data",
"from",
"resource",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/FireBaseStorage.php#L49-L56 |
asvae/laravel-api-tester | src/Storages/FireBaseStorage.php | FireBaseStorage.put | public function put(RequestCollection $data)
{
$this->store($data->onlyDiff());
$this->delete($data->onlyToDelete());
} | php | public function put(RequestCollection $data)
{
$this->store($data->onlyDiff());
$this->delete($data->onlyToDelete());
} | [
"public",
"function",
"put",
"(",
"RequestCollection",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"store",
"(",
"$",
"data",
"->",
"onlyDiff",
"(",
")",
")",
";",
"$",
"this",
"->",
"delete",
"(",
"$",
"data",
"->",
"onlyToDelete",
"(",
")",
")",
";... | Put data to resource.
@param $data RequestCollection
@return void | [
"Put",
"data",
"to",
"resource",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Storages/FireBaseStorage.php#L64-L68 |
asvae/laravel-api-tester | src/Http/Controllers/RequestController.php | RequestController.update | public function update(UpdateRequest $request)
{
$requestEntity = $this->repository->find($request->id);
// TODO What's happening in here?
if (!$requestEntity instanceof RequestEntity) {
return response(404);
}
$requestEntity->update($request->all());
$t... | php | public function update(UpdateRequest $request)
{
$requestEntity = $this->repository->find($request->id);
// TODO What's happening in here?
if (!$requestEntity instanceof RequestEntity) {
return response(404);
}
$requestEntity->update($request->all());
$t... | [
"public",
"function",
"update",
"(",
"UpdateRequest",
"$",
"request",
")",
"{",
"$",
"requestEntity",
"=",
"$",
"this",
"->",
"repository",
"->",
"find",
"(",
"$",
"request",
"->",
"id",
")",
";",
"// TODO What's happening in here?",
"if",
"(",
"!",
"$",
"... | @param \Asvae\ApiTester\Http\Requests\UpdateRequest $request
@param string $request
@return \Illuminate\Http\Response
@internal param int $id | [
"@param",
"\\",
"Asvae",
"\\",
"ApiTester",
"\\",
"Http",
"\\",
"Requests",
"\\",
"UpdateRequest",
"$request",
"@param",
"string",
"$request"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Http/Controllers/RequestController.php#L89-L102 |
asvae/laravel-api-tester | src/Providers/RouteServiceProvider.php | RouteServiceProvider.map | public function map(Router $router)
{
$router->group([
'as' => 'api-tester.',
'prefix' => config('api-tester.route'),
'namespace' => $this->getNamespace(),
'middleware' => $this->getMiddleware(),
], function () {
$this->requireRoutes();
... | php | public function map(Router $router)
{
$router->group([
'as' => 'api-tester.',
'prefix' => config('api-tester.route'),
'namespace' => $this->getNamespace(),
'middleware' => $this->getMiddleware(),
], function () {
$this->requireRoutes();
... | [
"public",
"function",
"map",
"(",
"Router",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"group",
"(",
"[",
"'as'",
"=>",
"'api-tester.'",
",",
"'prefix'",
"=>",
"config",
"(",
"'api-tester.route'",
")",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"get... | Define the routes for the application.
@param Router $router
@return void | [
"Define",
"the",
"routes",
"for",
"the",
"application",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Providers/RouteServiceProvider.php#L26-L36 |
asvae/laravel-api-tester | src/Repositories/RouteRepository.php | RouteRepository.get | public function get($match = [], $except = [])
{
foreach ($this->repositories as $repository) {
foreach ($repository->get($match, $except) as $route) {
$this->routes->push($route);
}
}
return $this->routes;
} | php | public function get($match = [], $except = [])
{
foreach ($this->repositories as $repository) {
foreach ($repository->get($match, $except) as $route) {
$this->routes->push($route);
}
}
return $this->routes;
} | [
"public",
"function",
"get",
"(",
"$",
"match",
"=",
"[",
"]",
",",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"repositories",
"as",
"$",
"repository",
")",
"{",
"foreach",
"(",
"$",
"repository",
"->",
"get",
"(",
... | @param array $match
@param array $except
@return mixed | [
"@param",
"array",
"$match",
"@param",
"array",
"$except"
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Repositories/RouteRepository.php#L37-L47 |
asvae/laravel-api-tester | src/Http/Controllers/RouteController.php | RouteController.index | public function index(RouteRepositoryInterface $repository)
{
$data = $repository->get(
config('api-tester.include'),
config('api-tester.exclude')
);
return response()->json(compact('data'));
} | php | public function index(RouteRepositoryInterface $repository)
{
$data = $repository->get(
config('api-tester.include'),
config('api-tester.exclude')
);
return response()->json(compact('data'));
} | [
"public",
"function",
"index",
"(",
"RouteRepositoryInterface",
"$",
"repository",
")",
"{",
"$",
"data",
"=",
"$",
"repository",
"->",
"get",
"(",
"config",
"(",
"'api-tester.include'",
")",
",",
"config",
"(",
"'api-tester.exclude'",
")",
")",
";",
"return",... | Display list of all available routes.
@param RouteRepositoryInterface $repository
@return \Illuminate\Http\JsonResponse | [
"Display",
"list",
"of",
"all",
"available",
"routes",
"."
] | train | https://github.com/asvae/laravel-api-tester/blob/7fd5d86bdcfc2b8c2e898c89b41feedf0c1b5e67/src/Http/Controllers/RouteController.php#L21-L29 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.cache | public function cache($path, $lifetime = 3600, $compress = true, $chmod = 0755) {
// if caching is not explicitly disabled
if ($path !== false) {
// if path doesn't exist, attempt to create it
if (!is_dir($path)) @mkdir($path, $chmod, true);
// save cache-related p... | php | public function cache($path, $lifetime = 3600, $compress = true, $chmod = 0755) {
// if caching is not explicitly disabled
if ($path !== false) {
// if path doesn't exist, attempt to create it
if (!is_dir($path)) @mkdir($path, $chmod, true);
// save cache-related p... | [
"public",
"function",
"cache",
"(",
"$",
"path",
",",
"$",
"lifetime",
"=",
"3600",
",",
"$",
"compress",
"=",
"true",
",",
"$",
"chmod",
"=",
"0755",
")",
"{",
"// if caching is not explicitly disabled",
"if",
"(",
"$",
"path",
"!==",
"false",
")",
"{",... | Use this method to enable caching of requests.
<i>Note that only the actual request is cached and not associated downloads, if any!</i>
<i>Caching is disabled by default!</i>
<code>
// the callback function to be executed for each and every
// request, as soon as a request finishes
// the callback function receives ... | [
"Use",
"this",
"method",
"to",
"enable",
"caching",
"of",
"requests",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L424-L443 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.cookies | public function cookies($path) {
// file does not exist
if (!is_file($path)) {
// attempt to create it
if (!($handle = fopen($path, 'a')))
// if file could not be created, trigger an error
trigger_error('File "' . $path . '" for storing cookies ... | php | public function cookies($path) {
// file does not exist
if (!is_file($path)) {
// attempt to create it
if (!($handle = fopen($path, 'a')))
// if file could not be created, trigger an error
trigger_error('File "' . $path . '" for storing cookies ... | [
"public",
"function",
"cookies",
"(",
"$",
"path",
")",
"{",
"// file does not exist",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"// attempt to create it",
"if",
"(",
"!",
"(",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"path",
",",
"'a'"... | Sets the path and name of the file to save to / retrieve cookies from. All cookie data will be stored in this
file on a per-domain basis. Important when cookies need to stored/restored to maintain status/session of requests
made to the same domains.
This method will automatically set the <b>CURLOPT_COOKIEJAR</b> and <... | [
"Sets",
"the",
"path",
"and",
"name",
"of",
"the",
"file",
"to",
"save",
"to",
"/",
"retrieve",
"cookies",
"from",
".",
"All",
"cookie",
"data",
"will",
"be",
"stored",
"in",
"this",
"file",
"on",
"a",
"per",
"-",
"domain",
"basis",
".",
"Important",
... | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L459-L481 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.download | public function download($urls, $path, $callback = '') {
// if destination path is not a directory or is not writable, trigger an error message
if (!is_dir($path) || !is_writable($path)) trigger_error('"' . $path . '" is not a valid path or is not writable', E_USER_ERROR);
// normalize URLs
... | php | public function download($urls, $path, $callback = '') {
// if destination path is not a directory or is not writable, trigger an error message
if (!is_dir($path) || !is_writable($path)) trigger_error('"' . $path . '" is not a valid path or is not writable', E_USER_ERROR);
// normalize URLs
... | [
"public",
"function",
"download",
"(",
"$",
"urls",
",",
"$",
"path",
",",
"$",
"callback",
"=",
"''",
")",
"{",
"// if destination path is not a directory or is not writable, trigger an error message",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
"||",
"!",
... | Downloads one or more files from one or more URLs, saves the downloaded files to the path specified by the
<i>$path</i> argument, and executes the callback function specified by the <i>$callback</i> argument for each and
every request, as soon as a request finishes.
<samp>If the path you are downloading from refers to... | [
"Downloads",
"one",
"or",
"more",
"files",
"from",
"one",
"or",
"more",
"URLs",
"saves",
"the",
"downloaded",
"files",
"to",
"the",
"path",
"specified",
"by",
"the",
"<i",
">",
"$path<",
"/",
"i",
">",
"argument",
"and",
"executes",
"the",
"callback",
"f... | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L898-L947 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.get | public function get($urls, $callback = '') {
// normalize URLs
// (transforms every allowed combination to the same type of array)
$urls = $this->_prepare_urls($urls);
// iterate through the list of URLs to process
foreach ($urls as $values)
// add each URL and ass... | php | public function get($urls, $callback = '') {
// normalize URLs
// (transforms every allowed combination to the same type of array)
$urls = $this->_prepare_urls($urls);
// iterate through the list of URLs to process
foreach ($urls as $values)
// add each URL and ass... | [
"public",
"function",
"get",
"(",
"$",
"urls",
",",
"$",
"callback",
"=",
"''",
")",
"{",
"// normalize URLs",
"// (transforms every allowed combination to the same type of array)",
"$",
"urls",
"=",
"$",
"this",
"->",
"_prepare_urls",
"(",
"$",
"urls",
")",
";",
... | Performs an HTTP <b>GET</b> request to one or more URLs and executes the callback function specified by the
<i>$callback</i> argument for each and every request, as soon as a request finishes.
This method will automatically set the following options:
- <b>CURLINFO_HEADER_OUT</b> - TRUE
- <b>CURLOPT_HEADER</b> - TRUE
... | [
"Performs",
"an",
"HTTP",
"<b",
">",
"GET<",
"/",
"b",
">",
"request",
"to",
"one",
"or",
"more",
"URLs",
"and",
"executes",
"the",
"callback",
"function",
"specified",
"by",
"the",
"<i",
">",
"$callback<",
"/",
"i",
">",
"argument",
"for",
"each",
"an... | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L1357-L1402 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.http_authentication | public function http_authentication($username = '', $password = '', $type = CURLAUTH_ANY) {
// set the required options
$this->option(array(
CURLOPT_HTTPAUTH => ($username == '' && $password == '' ? null : $type),
CURLOPT_USERPWD => ($username == '' && $password == '' ? null ... | php | public function http_authentication($username = '', $password = '', $type = CURLAUTH_ANY) {
// set the required options
$this->option(array(
CURLOPT_HTTPAUTH => ($username == '' && $password == '' ? null : $type),
CURLOPT_USERPWD => ($username == '' && $password == '' ? null ... | [
"public",
"function",
"http_authentication",
"(",
"$",
"username",
"=",
"''",
",",
"$",
"password",
"=",
"''",
",",
"$",
"type",
"=",
"CURLAUTH_ANY",
")",
"{",
"// set the required options",
"$",
"this",
"->",
"option",
"(",
"array",
"(",
"CURLOPT_HTTPAUTH",
... | Use this method to make requests to pages that require prior HTTP authentication.
<code>
// the callback function to be executed for each and every
// request, as soon as a request finishes
// the callback function receives as argument an object with 4 properties
// (info, header, body and response)
function mycallbac... | [
"Use",
"this",
"method",
"to",
"make",
"requests",
"to",
"pages",
"that",
"require",
"prior",
"HTTP",
"authentication",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L1670-L1678 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.option | public function option($option, $value = '') {
// if $options is given as an array
if (is_array($option))
// iterate through each of the values
foreach ($option as $name => $value)
// if we need to "unset" an option, unset it
if (is_null($value)... | php | public function option($option, $value = '') {
// if $options is given as an array
if (is_array($option))
// iterate through each of the values
foreach ($option as $name => $value)
// if we need to "unset" an option, unset it
if (is_null($value)... | [
"public",
"function",
"option",
"(",
"$",
"option",
",",
"$",
"value",
"=",
"''",
")",
"{",
"// if $options is given as an array",
"if",
"(",
"is_array",
"(",
"$",
"option",
")",
")",
"// iterate through each of the values",
"foreach",
"(",
"$",
"option",
"as",
... | Allows you to set one or more {@link http://php.net/manual/en/function.curl-setopt.php cURL options}.
<code>
// include the Zebra_cURL library
require 'path/to/Zebra_cURL';
// instantiate the Zebra_cURL object
$curl = new Zebra_cURL();
// setting a single option
$curl->option(CURLOPT_CONNECTTIMEOUT, 10);
// setting... | [
"Allows",
"you",
"to",
"set",
"one",
"or",
"more",
"{",
"@link",
"http",
":",
"//",
"php",
".",
"net",
"/",
"manual",
"/",
"en",
"/",
"function",
".",
"curl",
"-",
"setopt",
".",
"php",
"cURL",
"options",
"}",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L1717-L1738 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.proxy | public function proxy($proxy, $port = 80, $username = '', $password = '') {
// if not disabled
if ($proxy) {
// set the required options
$this->option(array(
CURLOPT_HTTPPROXYTUNNEL => 1,
CURLOPT_PROXY => $proxy,
... | php | public function proxy($proxy, $port = 80, $username = '', $password = '') {
// if not disabled
if ($proxy) {
// set the required options
$this->option(array(
CURLOPT_HTTPPROXYTUNNEL => 1,
CURLOPT_PROXY => $proxy,
... | [
"public",
"function",
"proxy",
"(",
"$",
"proxy",
",",
"$",
"port",
"=",
"80",
",",
"$",
"username",
"=",
"''",
",",
"$",
"password",
"=",
"''",
")",
"{",
"// if not disabled",
"if",
"(",
"$",
"proxy",
")",
"{",
"// set the required options",
"$",
"thi... | Instruct the library to tunnel all requests through a proxy server.
<code>
// the callback function to be executed for each and every
// request, as soon as a request finishes
function mycallback($result) {
// everything went well at cURL level
if ($result->response[1] == CURLE_OK) {
// if server responded with code... | [
"Instruct",
"the",
"library",
"to",
"tunnel",
"all",
"requests",
"through",
"a",
"proxy",
"server",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2083-L2111 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.scrap | public function scrap($url, $body_only = true) {
// this method requires the $url argument to be a string
if (is_array($url)) trigger_error('URL must be a string', E_USER_ERROR);
// make the request
$this->get($url, function($result) {
// store result in this private prope... | php | public function scrap($url, $body_only = true) {
// this method requires the $url argument to be a string
if (is_array($url)) trigger_error('URL must be a string', E_USER_ERROR);
// make the request
$this->get($url, function($result) {
// store result in this private prope... | [
"public",
"function",
"scrap",
"(",
"$",
"url",
",",
"$",
"body_only",
"=",
"true",
")",
"{",
"// this method requires the $url argument to be a string",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
")",
"trigger_error",
"(",
"'URL must be a string'",
",",
"E_USER... | A shorthand for making <b>a single</b> {@link get} request without the need of a callback function
<code>
// include the Zebra_cURL library
require 'path/to/Zebra_cURL';
// instantiate the class
$curl = new Zebra_cURL();
// get page's content only
$content = $curl->scrap('https://www.somewebsite.com/');
// print th... | [
"A",
"shorthand",
"for",
"making",
"<b",
">",
"a",
"single<",
"/",
"b",
">",
"{",
"@link",
"get",
"}",
"request",
"without",
"the",
"need",
"of",
"a",
"callback",
"function"
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2495-L2511 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.ssl | public function ssl($verify_peer = true, $verify_host = 2, $file = false, $path = false) {
// set default options
$this->option(array(
CURLOPT_SSL_VERIFYPEER => $verify_peer,
CURLOPT_SSL_VERIFYHOST => $verify_host,
));
// if a path to a file holding one or more certif... | php | public function ssl($verify_peer = true, $verify_host = 2, $file = false, $path = false) {
// set default options
$this->option(array(
CURLOPT_SSL_VERIFYPEER => $verify_peer,
CURLOPT_SSL_VERIFYHOST => $verify_host,
));
// if a path to a file holding one or more certif... | [
"public",
"function",
"ssl",
"(",
"$",
"verify_peer",
"=",
"true",
",",
"$",
"verify_host",
"=",
"2",
",",
"$",
"file",
"=",
"false",
",",
"$",
"path",
"=",
"false",
")",
"{",
"// set default options",
"$",
"this",
"->",
"option",
"(",
"array",
"(",
... | Requests made to HTTPS servers sometimes require additional configuration, depending on the server. Most of the
times {@link __construct() the defaults} set by the library will get you through, but if defaults are not working,
you can set specific options using this method.
<code>
// include the Zebra_cURL library
req... | [
"Requests",
"made",
"to",
"HTTPS",
"servers",
"sometimes",
"require",
"additional",
"configuration",
"depending",
"on",
"the",
"server",
".",
"Most",
"of",
"the",
"times",
"{",
"@link",
"__construct",
"()",
"the",
"defaults",
"}",
"set",
"by",
"the",
"library"... | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2584-L2610 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL.start | public function start() {
// indicate the library that it should execute queued requests
$this->_queue = false;
// if we have to pause between batches of requests, process them sequentially, in batches
if ($this->pause_interval > 0) $this->_process_paused();
// if we don't hav... | php | public function start() {
// indicate the library that it should execute queued requests
$this->_queue = false;
// if we have to pause between batches of requests, process them sequentially, in batches
if ($this->pause_interval > 0) $this->_process_paused();
// if we don't hav... | [
"public",
"function",
"start",
"(",
")",
"{",
"// indicate the library that it should execute queued requests",
"$",
"this",
"->",
"_queue",
"=",
"false",
";",
"// if we have to pause between batches of requests, process them sequentially, in batches",
"if",
"(",
"$",
"this",
"... | Executes queued requests.
See {@link queue} method for more information.
@since 1.3.0
@return void | [
"Executes",
"queued",
"requests",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2621-L2632 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._debug | private function _debug() {
$result = '';
// iterate through the defined constants
foreach(get_defined_constants() as $name => $number)
// iterate through the set options
foreach ($this->options as $index => $value)
// if this is a curl-related constan... | php | private function _debug() {
$result = '';
// iterate through the defined constants
foreach(get_defined_constants() as $name => $number)
// iterate through the set options
foreach ($this->options as $index => $value)
// if this is a curl-related constan... | [
"private",
"function",
"_debug",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"// iterate through the defined constants",
"foreach",
"(",
"get_defined_constants",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"number",
")",
"// iterate through the set options",
"foreach"... | Returns the currently set options in "human-readable" format.
@return string Returns the set options in "human-readable" format.
@access private | [
"Returns",
"the",
"currently",
"set",
"options",
"in",
"human",
"-",
"readable",
"format",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2641-L2657 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._get_cache_file_name | private function _get_cache_file_name($request) {
// iterate through the options associated with the request
foreach ($request['options'] as $key => $value)
// ...and remove null or empty values
if (is_null($value) || $value == '') unset($request['options'][$key]);
// ... | php | private function _get_cache_file_name($request) {
// iterate through the options associated with the request
foreach ($request['options'] as $key => $value)
// ...and remove null or empty values
if (is_null($value) || $value == '') unset($request['options'][$key]);
// ... | [
"private",
"function",
"_get_cache_file_name",
"(",
"$",
"request",
")",
"{",
"// iterate through the options associated with the request",
"foreach",
"(",
"$",
"request",
"[",
"'options'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"// ...and remove null or empty ... | Returns the cache file name associated with a specific request.
@return string Returns the set options in "human-readable" format.
@access private | [
"Returns",
"the",
"cache",
"file",
"name",
"associated",
"with",
"a",
"specific",
"request",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2666-L2681 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._parse_headers | private function _parse_headers($headers) {
$result = array();
// if we have nothing to work with
if ($headers != '') {
// split multiple headers by blank lines
$headers = preg_split('/^\s*$/m', trim($headers));
// iterate through the headers
f... | php | private function _parse_headers($headers) {
$result = array();
// if we have nothing to work with
if ($headers != '') {
// split multiple headers by blank lines
$headers = preg_split('/^\s*$/m', trim($headers));
// iterate through the headers
f... | [
"private",
"function",
"_parse_headers",
"(",
"$",
"headers",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// if we have nothing to work with",
"if",
"(",
"$",
"headers",
"!=",
"''",
")",
"{",
"// split multiple headers by blank lines",
"$",
"headers",
... | Parse response headers.
It parses a string containing one or more HTTP headers and returns an array of headers where each entry also
contains an associative array of <i>name</i> => <i>value</i> for each row of data in the respective header.
@param string $headers A string containing one or more HTTP headers, whe... | [
"Parse",
"response",
"headers",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2699-L2731 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._prepare_urls | private function _prepare_urls($urls) {
// if $urls is *one* associative array containing one of "url", "options" and "data" entries
if (is_array($urls) && !empty(array_intersect(array('url', 'options', 'data'), array_keys($urls)))) {
// since "url" is mandatory, stop if not present
... | php | private function _prepare_urls($urls) {
// if $urls is *one* associative array containing one of "url", "options" and "data" entries
if (is_array($urls) && !empty(array_intersect(array('url', 'options', 'data'), array_keys($urls)))) {
// since "url" is mandatory, stop if not present
... | [
"private",
"function",
"_prepare_urls",
"(",
"$",
"urls",
")",
"{",
"// if $urls is *one* associative array containing one of \"url\", \"options\" and \"data\" entries",
"if",
"(",
"is_array",
"(",
"$",
"urls",
")",
"&&",
"!",
"empty",
"(",
"array_intersect",
"(",
"array"... | Normalizes URLs.
Since URLs can be given as a string, an array of URLs, one associative array or an array of associative arrays,
this method normalizes all of those into an array of associative arrays.
@return array
@access private | [
"Normalizes",
"URLs",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2743-L2837 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._process | private function _process() {
// if caching is enabled but path doesn't exist, or is not writable
if ($this->cache !== false && (!is_dir($this->cache['path']) || !is_writable($this->cache['path'])))
// trigger an error and stop execution
trigger_error('Cache path does not exist... | php | private function _process() {
// if caching is enabled but path doesn't exist, or is not writable
if ($this->cache !== false && (!is_dir($this->cache['path']) || !is_writable($this->cache['path'])))
// trigger an error and stop execution
trigger_error('Cache path does not exist... | [
"private",
"function",
"_process",
"(",
")",
"{",
"// if caching is enabled but path doesn't exist, or is not writable",
"if",
"(",
"$",
"this",
"->",
"cache",
"!==",
"false",
"&&",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"cache",
"[",
"'path'",
"]",
")",
... | Does the actual work.
@return void
@access private | [
"Does",
"the",
"actual",
"work",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L2846-L3089 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._process_paused | private function _process_paused() {
// copy all requests to another variable
$urls = $this->_requests;
// while there are URLs to process
while (!empty($urls)) {
// get from the entire list of requests as many as specified by the "threads" property
$this->_req... | php | private function _process_paused() {
// copy all requests to another variable
$urls = $this->_requests;
// while there are URLs to process
while (!empty($urls)) {
// get from the entire list of requests as many as specified by the "threads" property
$this->_req... | [
"private",
"function",
"_process_paused",
"(",
")",
"{",
"// copy all requests to another variable",
"$",
"urls",
"=",
"$",
"this",
"->",
"_requests",
";",
"// while there are URLs to process",
"while",
"(",
"!",
"empty",
"(",
"$",
"urls",
")",
")",
"{",
"// get f... | A wrapper for the {@link _process} method used when we need to pause between batches of requests to
process.
@return void
@access private | [
"A",
"wrapper",
"for",
"the",
"{",
"@link",
"_process",
"}",
"method",
"used",
"when",
"we",
"need",
"to",
"pause",
"between",
"batches",
"of",
"requests",
"to",
"process",
"."
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L3099-L3118 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._queue_requests | private function _queue_requests() {
// get the number of remaining urls
$requests_count = count($this->_requests);
// iterate through the items in the queue
for ($i = 0; $i < ($requests_count < $this->threads ? $requests_count : $this->threads); $i++) {
// remove the firs... | php | private function _queue_requests() {
// get the number of remaining urls
$requests_count = count($this->_requests);
// iterate through the items in the queue
for ($i = 0; $i < ($requests_count < $this->threads ? $requests_count : $this->threads); $i++) {
// remove the firs... | [
"private",
"function",
"_queue_requests",
"(",
")",
"{",
"// get the number of remaining urls",
"$",
"requests_count",
"=",
"count",
"(",
"$",
"this",
"->",
"_requests",
")",
";",
"// iterate through the items in the queue",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$... | A helper method used by the {@link _process} method, taking care of keeping a constant number of requests
queued, so that as soon as one request finishes another one will instantly take its place, thus making sure that
the maximum allowed number of parallel threads are running all the time.
@return void
@access priva... | [
"A",
"helper",
"method",
"used",
"by",
"the",
"{",
"@link",
"_process",
"}",
"method",
"taking",
"care",
"of",
"keeping",
"a",
"constant",
"number",
"of",
"requests",
"queued",
"so",
"that",
"as",
"soon",
"as",
"one",
"request",
"finishes",
"another",
"one... | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L3129-L3198 |
stefangabos/Zebra_cURL | Zebra_cURL.php | Zebra_cURL._user_agent | private function _user_agent() {
// browser version: 9 or 10
$version = rand(9, 10);
// windows version; here are the meanings:
// Windows NT 6.2 -> Windows 8 // can have IE10
// Windows NT 6.1 -> Windows 7 ... | php | private function _user_agent() {
// browser version: 9 or 10
$version = rand(9, 10);
// windows version; here are the meanings:
// Windows NT 6.2 -> Windows 8 // can have IE10
// Windows NT 6.1 -> Windows 7 ... | [
"private",
"function",
"_user_agent",
"(",
")",
"{",
"// browser version: 9 or 10",
"$",
"version",
"=",
"rand",
"(",
"9",
",",
"10",
")",
";",
"// windows version; here are the meanings:",
"// Windows NT 6.2 -> Windows 8 // can have IE10... | Generates a (slightly) random user agent (Internet Explorer 9 or 10, on Windows Vista, 7 or 8, with other extra
strings)
Some web services will not respond unless a valid user-agent string is provided.
@return void
@access private | [
"Generates",
"a",
"(",
"slightly",
")",
"random",
"user",
"agent",
"(",
"Internet",
"Explorer",
"9",
"or",
"10",
"on",
"Windows",
"Vista",
"7",
"or",
"8",
"with",
"other",
"extra",
"strings",
")"
] | train | https://github.com/stefangabos/Zebra_cURL/blob/bf9f5b27ca5783cba97f51243bf1354ab18c1483/Zebra_cURL.php#L3210-L3235 |
MattKetmo/EmailChecker | src/EmailChecker/Constraints/NotThrowawayEmailValidator.php | NotThrowawayEmailValidator.validate | public function validate($value, Constraint $constraint)
{
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
... | php | public function validate($value, Constraint $constraint)
{
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
... | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
"||",
"''",
"===",
"$",
"value",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"valu... | {@inheritdoc} | [
"{"
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/Constraints/NotThrowawayEmailValidator.php#L38-L51 |
MattKetmo/EmailChecker | src/EmailChecker/Laravel/EmailCheckerServiceProvider.php | EmailCheckerServiceProvider.register | public function register()
{
/*
* Register the e-mail checker
*/
$this->app->singleton(EmailChecker::class, function ($app) {
return new EmailChecker();
});
/*
* Alias the dependency for ease.
*/
$this->app->alias(EmailChecker:... | php | public function register()
{
/*
* Register the e-mail checker
*/
$this->app->singleton(EmailChecker::class, function ($app) {
return new EmailChecker();
});
/*
* Alias the dependency for ease.
*/
$this->app->alias(EmailChecker:... | [
"public",
"function",
"register",
"(",
")",
"{",
"/*\n * Register the e-mail checker\n */",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"EmailChecker",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"EmailChecker"... | Register the factory in the application container. | [
"Register",
"the",
"factory",
"in",
"the",
"application",
"container",
"."
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/Laravel/EmailCheckerServiceProvider.php#L28-L41 |
MattKetmo/EmailChecker | src/EmailChecker/Laravel/EmailCheckerServiceProvider.php | EmailCheckerServiceProvider.boot | public function boot(EmailChecker $checker)
{
/*
* Add a custom validator filter.
*/
$check = function ($attr, $value, $param, $validator) use ($checker) {
return $checker->isValid($value);
};
Validator::extend(
'not_throw_away', $check, 'Th... | php | public function boot(EmailChecker $checker)
{
/*
* Add a custom validator filter.
*/
$check = function ($attr, $value, $param, $validator) use ($checker) {
return $checker->isValid($value);
};
Validator::extend(
'not_throw_away', $check, 'Th... | [
"public",
"function",
"boot",
"(",
"EmailChecker",
"$",
"checker",
")",
"{",
"/*\n * Add a custom validator filter.\n */",
"$",
"check",
"=",
"function",
"(",
"$",
"attr",
",",
"$",
"value",
",",
"$",
"param",
",",
"$",
"validator",
")",
"use",
... | Bootstrap any application services. | [
"Bootstrap",
"any",
"application",
"services",
"."
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/Laravel/EmailCheckerServiceProvider.php#L46-L58 |
MattKetmo/EmailChecker | src/EmailChecker/Adapter/AgregatorAdapter.php | AgregatorAdapter.isThrowawayDomain | public function isThrowawayDomain($domain)
{
foreach ($this->adapters as $adapter) {
if ($adapter->isThrowawayDomain($domain)) {
return true;
}
}
return false;
} | php | public function isThrowawayDomain($domain)
{
foreach ($this->adapters as $adapter) {
if ($adapter->isThrowawayDomain($domain)) {
return true;
}
}
return false;
} | [
"public",
"function",
"isThrowawayDomain",
"(",
"$",
"domain",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"adapters",
"as",
"$",
"adapter",
")",
"{",
"if",
"(",
"$",
"adapter",
"->",
"isThrowawayDomain",
"(",
"$",
"domain",
")",
")",
"{",
"return",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/Adapter/AgregatorAdapter.php#L44-L53 |
MattKetmo/EmailChecker | src/EmailChecker/Utilities.php | Utilities.parseEmailAddress | public static function parseEmailAddress($email)
{
$pattern = sprintf('/^(?<local>%s)@(?<domain>%s)$/iD', self::EMAIL_REGEX_LOCAL, self::EMAIL_REGEX_DOMAIN);
if (!preg_match($pattern, $email, $parts)) {
throw new InvalidEmailException(sprintf('"%s" is not a valid email', $email));
... | php | public static function parseEmailAddress($email)
{
$pattern = sprintf('/^(?<local>%s)@(?<domain>%s)$/iD', self::EMAIL_REGEX_LOCAL, self::EMAIL_REGEX_DOMAIN);
if (!preg_match($pattern, $email, $parts)) {
throw new InvalidEmailException(sprintf('"%s" is not a valid email', $email));
... | [
"public",
"static",
"function",
"parseEmailAddress",
"(",
"$",
"email",
")",
"{",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/^(?<local>%s)@(?<domain>%s)$/iD'",
",",
"self",
"::",
"EMAIL_REGEX_LOCAL",
",",
"self",
"::",
"EMAIL_REGEX_DOMAIN",
")",
";",
"if",
"(",
"!"... | Extract parts of an email address.
@param string $email The email address to parse
@return array The parts of the email. First the local part, then the domain | [
"Extract",
"parts",
"of",
"an",
"email",
"address",
"."
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/Utilities.php#L33-L42 |
MattKetmo/EmailChecker | src/EmailChecker/Utilities.php | Utilities.parseLines | public static function parseLines($content)
{
// Split by line
$lines = explode("\n", $content);
// Trim and convert to lowercase
$lines = array_map('trim', $lines);
$lines = array_map('strtolower', $lines);
// Remove empty lines and comments
$lines = array_... | php | public static function parseLines($content)
{
// Split by line
$lines = explode("\n", $content);
// Trim and convert to lowercase
$lines = array_map('trim', $lines);
$lines = array_map('strtolower', $lines);
// Remove empty lines and comments
$lines = array_... | [
"public",
"static",
"function",
"parseLines",
"(",
"$",
"content",
")",
"{",
"// Split by line",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"content",
")",
";",
"// Trim and convert to lowercase",
"$",
"lines",
"=",
"array_map",
"(",
"'trim'",
","... | Parse content and extract lines.
@param string $content The content to parse
@return array Array of cleaned string | [
"Parse",
"content",
"and",
"extract",
"lines",
"."
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/Utilities.php#L51-L66 |
MattKetmo/EmailChecker | src/EmailChecker/EmailChecker.php | EmailChecker.isValid | public function isValid($email)
{
if (false === $email = filter_var($email, FILTER_VALIDATE_EMAIL)) {
return false;
}
try {
list($local, $domain) = Utilities::parseEmailAddress($email);
} catch (InvalidEmailException $e) {
return false;
}
... | php | public function isValid($email)
{
if (false === $email = filter_var($email, FILTER_VALIDATE_EMAIL)) {
return false;
}
try {
list($local, $domain) = Utilities::parseEmailAddress($email);
} catch (InvalidEmailException $e) {
return false;
}
... | [
"public",
"function",
"isValid",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"email",
"=",
"filter_var",
"(",
"$",
"email",
",",
"FILTER_VALIDATE_EMAIL",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"list",
"(",
"$",
"loca... | Check if it's a valid email, ie. not a throwaway email.
@param string $email The email to check
@return bool true for a throwaway email | [
"Check",
"if",
"it",
"s",
"a",
"valid",
"email",
"ie",
".",
"not",
"a",
"throwaway",
"email",
"."
] | train | https://github.com/MattKetmo/EmailChecker/blob/678a50f4ccb9e13f16116fffa8d93ab70b83553d/src/EmailChecker/EmailChecker.php#L42-L55 |
drutiny/drutiny | src/Assessment.php | Assessment.assessTarget | public function assessTarget(TargetInterface $target, array $policies, \DateTime $start = NULL, \DateTime $end = NULL, $remediate = FALSE)
{
$start = $start ?: new \DateTime('-1 day');
$end = $end ?: new \DateTime();
$policies = array_filter($policies, function ($policy) {
return $policy instance... | php | public function assessTarget(TargetInterface $target, array $policies, \DateTime $start = NULL, \DateTime $end = NULL, $remediate = FALSE)
{
$start = $start ?: new \DateTime('-1 day');
$end = $end ?: new \DateTime();
$policies = array_filter($policies, function ($policy) {
return $policy instance... | [
"public",
"function",
"assessTarget",
"(",
"TargetInterface",
"$",
"target",
",",
"array",
"$",
"policies",
",",
"\\",
"DateTime",
"$",
"start",
"=",
"NULL",
",",
"\\",
"DateTime",
"$",
"end",
"=",
"NULL",
",",
"$",
"remediate",
"=",
"FALSE",
")",
"{",
... | Assess a Target.
@param TargetInterface $target
@param array $policies each item should be a Drutiny\Policy object.
@param DateTime $start The start date of the reporting period. Defaults to -1 day.
@param DateTime $end The end date of the reporting period. Defaults to now.
@param bool $remediate If an Drutiny\Audit s... | [
"Assess",
"a",
"Target",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Assessment.php#L39-L76 |
drutiny/drutiny | src/Assessment.php | Assessment.setPolicyResult | public function setPolicyResult(AuditResponse $response)
{
$this->results[$response->getPolicy()->get('name')] = $response;
// Set the overall success state of the Assessment. Considered
// a success if all policies pass.
$this->successful = $this->successful && $response->isSuccessful();
// If ... | php | public function setPolicyResult(AuditResponse $response)
{
$this->results[$response->getPolicy()->get('name')] = $response;
// Set the overall success state of the Assessment. Considered
// a success if all policies pass.
$this->successful = $this->successful && $response->isSuccessful();
// If ... | [
"public",
"function",
"setPolicyResult",
"(",
"AuditResponse",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"results",
"[",
"$",
"response",
"->",
"getPolicy",
"(",
")",
"->",
"get",
"(",
"'name'",
")",
"]",
"=",
"$",
"response",
";",
"// Set the overall ... | Set the result of a Policy.
The result of a Policy is unique to an assessment result set.
@param AuditResponse $response | [
"Set",
"the",
"result",
"of",
"a",
"Policy",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Assessment.php#L85-L100 |
drutiny/drutiny | src/Assessment.php | Assessment.getPolicyResult | public function getPolicyResult($name)
{
if (!isset($this->results[$name])) {
throw new NoAuditResponseFoundException($name, "Policy '$name' does not have an AuditResponse.");
}
return $this->results[$name];
} | php | public function getPolicyResult($name)
{
if (!isset($this->results[$name])) {
throw new NoAuditResponseFoundException($name, "Policy '$name' does not have an AuditResponse.");
}
return $this->results[$name];
} | [
"public",
"function",
"getPolicyResult",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"results",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"NoAuditResponseFoundException",
"(",
"$",
"name",
",",
"\"Policy '$nam... | Get an AuditResponse object by Policy name.
@param string $name
@return AuditResponse | [
"Get",
"an",
"AuditResponse",
"object",
"by",
"Policy",
"name",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Assessment.php#L115-L121 |
drutiny/drutiny | src/PolicySource/DrutinyGitHubIO.php | DrutinyGitHubIO.getList | public function getList()
{
$api = new Api();
$list = [];
foreach ($api->getPolicyList() as $listedPolicy) {
$list[$listedPolicy['name']] = $listedPolicy;
}
return $list;
} | php | public function getList()
{
$api = new Api();
$list = [];
foreach ($api->getPolicyList() as $listedPolicy) {
$list[$listedPolicy['name']] = $listedPolicy;
}
return $list;
} | [
"public",
"function",
"getList",
"(",
")",
"{",
"$",
"api",
"=",
"new",
"Api",
"(",
")",
";",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"api",
"->",
"getPolicyList",
"(",
")",
"as",
"$",
"listedPolicy",
")",
"{",
"$",
"list",
"[",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/PolicySource/DrutinyGitHubIO.php#L22-L30 |
drutiny/drutiny | src/PolicySource/DrutinyGitHubIO.php | DrutinyGitHubIO.load | public function load(array $definition)
{
$cache = Container::cache('drutiny.github.io.policy');
$item = $cache->getItem($definition['signature']);
if ($item->isHit()) {
Container::getLogger()->info("Cache hit for {$definition['name']} from " . $this->getName());
return new Policy($item->get... | php | public function load(array $definition)
{
$cache = Container::cache('drutiny.github.io.policy');
$item = $cache->getItem($definition['signature']);
if ($item->isHit()) {
Container::getLogger()->info("Cache hit for {$definition['name']} from " . $this->getName());
return new Policy($item->get... | [
"public",
"function",
"load",
"(",
"array",
"$",
"definition",
")",
"{",
"$",
"cache",
"=",
"Container",
"::",
"cache",
"(",
"'drutiny.github.io.policy'",
")",
";",
"$",
"item",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"$",
"definition",
"[",
"'signature'"... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/PolicySource/DrutinyGitHubIO.php#L35-L57 |
drutiny/drutiny | src/Audit/Database/DatabaseSize.php | DatabaseSize.audit | public function audit(Sandbox $sandbox) {
$stat = $sandbox->drush(['format' => 'json'])
->status();
$name = $stat['db-name'];
$sql = "SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) 'DB Size in MB'
FROM information_schema.tables
WHERE table_schema='{$name}'
... | php | public function audit(Sandbox $sandbox) {
$stat = $sandbox->drush(['format' => 'json'])
->status();
$name = $stat['db-name'];
$sql = "SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) 'DB Size in MB'
FROM information_schema.tables
WHERE table_schema='{$name}'
... | [
"public",
"function",
"audit",
"(",
"Sandbox",
"$",
"sandbox",
")",
"{",
"$",
"stat",
"=",
"$",
"sandbox",
"->",
"drush",
"(",
"[",
"'format'",
"=>",
"'json'",
"]",
")",
"->",
"status",
"(",
")",
";",
"$",
"name",
"=",
"$",
"stat",
"[",
"'db-name'"... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Audit/Database/DatabaseSize.php#L39-L67 |
drutiny/drutiny | src/Policy/PolicyBase.php | PolicyBase.render | protected function render($markdown, $replacements) {
$m = new \Mustache_Engine();
try {
return $m->render($markdown, $replacements);
}
catch (\Mustache_Exception $e) {
throw new \Exception("Error in $this->name: " . $e->getMessage());
}
} | php | protected function render($markdown, $replacements) {
$m = new \Mustache_Engine();
try {
return $m->render($markdown, $replacements);
}
catch (\Mustache_Exception $e) {
throw new \Exception("Error in $this->name: " . $e->getMessage());
}
} | [
"protected",
"function",
"render",
"(",
"$",
"markdown",
",",
"$",
"replacements",
")",
"{",
"$",
"m",
"=",
"new",
"\\",
"Mustache_Engine",
"(",
")",
";",
"try",
"{",
"return",
"$",
"m",
"->",
"render",
"(",
"$",
"markdown",
",",
"$",
"replacements",
... | Render a property. | [
"Render",
"a",
"property",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Policy/PolicyBase.php#L75-L83 |
drutiny/drutiny | src/Policy/PolicyBase.php | PolicyBase.get | public function get($property, $replacements = []) {
if (!isset($this->{$property})) {
throw new \Exception("Attempt to retrieve unknown property: $property. Available properties: \n" . print_r((array) $this, 1));
}
if (in_array($property, $this->renderableProperties)) {
return $this->render($th... | php | public function get($property, $replacements = []) {
if (!isset($this->{$property})) {
throw new \Exception("Attempt to retrieve unknown property: $property. Available properties: \n" . print_r((array) $this, 1));
}
if (in_array($property, $this->renderableProperties)) {
return $this->render($th... | [
"public",
"function",
"get",
"(",
"$",
"property",
",",
"$",
"replacements",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"property",
"}",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Attempt to r... | Retrieve a property value and token replacement. | [
"Retrieve",
"a",
"property",
"value",
"and",
"token",
"replacement",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Policy/PolicyBase.php#L88-L96 |
drutiny/drutiny | src/Driver/DrushHelper.php | DrushHelper.variable_get | public function variable_get($name, $default = NULL)
{
$vars = $this->drush->setDrushOptions(['format' => 'json'])->variableGet();
if (!isset($vars[$name])) {
return $default;
}
return $vars[$name];
} | php | public function variable_get($name, $default = NULL)
{
$vars = $this->drush->setDrushOptions(['format' => 'json'])->variableGet();
if (!isset($vars[$name])) {
return $default;
}
return $vars[$name];
} | [
"public",
"function",
"variable_get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"vars",
"=",
"$",
"this",
"->",
"drush",
"->",
"setDrushOptions",
"(",
"[",
"'format'",
"=>",
"'json'",
"]",
")",
"->",
"variableGet",
"(",
")",
... | Function like the Drupal 7 variable_get function.
@param $name
The name of the variable (exact).
@param mixed $default
The value to return if the variable is not set. | [
"Function",
"like",
"the",
"Drupal",
"7",
"variable_get",
"function",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushHelper.php#L25-L32 |
drutiny/drutiny | src/Profile/ProfileSource.php | ProfileSource.loadProfileByName | public static function loadProfileByName($name)
{
$list = self::getProfileList();
$definition = $list[$name];
return self::getSource($definition['source'])->load($definition);
} | php | public static function loadProfileByName($name)
{
$list = self::getProfileList();
$definition = $list[$name];
return self::getSource($definition['source'])->load($definition);
} | [
"public",
"static",
"function",
"loadProfileByName",
"(",
"$",
"name",
")",
"{",
"$",
"list",
"=",
"self",
"::",
"getProfileList",
"(",
")",
";",
"$",
"definition",
"=",
"$",
"list",
"[",
"$",
"name",
"]",
";",
"return",
"self",
"::",
"getSource",
"(",... | Load policy by name.
@param $name string | [
"Load",
"policy",
"by",
"name",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSource.php#L15-L21 |
drutiny/drutiny | src/Profile/ProfileSource.php | ProfileSource.getProfileList | public static function getProfileList()
{
static $list;
if (!empty($list)) {
return $list;
}
$lists = array_map(function ($source) {
return array_map(function ($item) use ($source) {
$item['source'] = $source->getName();
return $item;
},
$source->getList());
... | php | public static function getProfileList()
{
static $list;
if (!empty($list)) {
return $list;
}
$lists = array_map(function ($source) {
return array_map(function ($item) use ($source) {
$item['source'] = $source->getName();
return $item;
},
$source->getList());
... | [
"public",
"static",
"function",
"getProfileList",
"(",
")",
"{",
"static",
"$",
"list",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"return",
"$",
"list",
";",
"}",
"$",
"lists",
"=",
"array_map",
"(",
"function",
"(",
"$",
"sour... | Acquire a list of available policies.
@return array of policy information arrays. | [
"Acquire",
"a",
"list",
"of",
"available",
"policies",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSource.php#L28-L45 |
drutiny/drutiny | src/Profile/ProfileSource.php | ProfileSource.loadAll | public static function loadAll()
{
$list = [];
foreach (self::getProfileList() as $definition) {
$list[$definition['name']] = self::loadProfileByName($definition['name']);
}
return $list;
} | php | public static function loadAll()
{
$list = [];
foreach (self::getProfileList() as $definition) {
$list[$definition['name']] = self::loadProfileByName($definition['name']);
}
return $list;
} | [
"public",
"static",
"function",
"loadAll",
"(",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"getProfileList",
"(",
")",
"as",
"$",
"definition",
")",
"{",
"$",
"list",
"[",
"$",
"definition",
"[",
"'name'",
"]",
"]",
"=... | Load all policies as loaded Policy objects. | [
"Load",
"all",
"policies",
"as",
"loaded",
"Policy",
"objects",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSource.php#L50-L57 |
drutiny/drutiny | src/Profile/ProfileSource.php | ProfileSource.getSources | public static function getSources()
{
$item = Container::cache(__CLASS__)->getItem('sources');
if ($item->isHit()) {
return $item->get();
}
// The PolicySource config directive loads in class names that provides
// policies for Drutiny to use. We need to validate each provided source
//... | php | public static function getSources()
{
$item = Container::cache(__CLASS__)->getItem('sources');
if ($item->isHit()) {
return $item->get();
}
// The PolicySource config directive loads in class names that provides
// policies for Drutiny to use. We need to validate each provided source
//... | [
"public",
"static",
"function",
"getSources",
"(",
")",
"{",
"$",
"item",
"=",
"Container",
"::",
"cache",
"(",
"__CLASS__",
")",
"->",
"getItem",
"(",
"'sources'",
")",
";",
"if",
"(",
"$",
"item",
"->",
"isHit",
"(",
")",
")",
"{",
"return",
"$",
... | Load the sources that provide policies.
@return array of PolicySourceInterface objects. | [
"Load",
"the",
"sources",
"that",
"provide",
"policies",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSource.php#L64-L95 |
drutiny/drutiny | src/Profile/ProfileSource.php | ProfileSource.getSource | public static function getSource($name)
{
foreach (self::getSources() as $source) {
if ($source->getName() == $name) {
return $source;
}
}
throw new \Exception("ProfileSource not found: $name.");
} | php | public static function getSource($name)
{
foreach (self::getSources() as $source) {
if ($source->getName() == $name) {
return $source;
}
}
throw new \Exception("ProfileSource not found: $name.");
} | [
"public",
"static",
"function",
"getSource",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"self",
"::",
"getSources",
"(",
")",
"as",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"return"... | Load a single source. | [
"Load",
"a",
"single",
"source",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSource.php#L100-L108 |
drutiny/drutiny | src/Sandbox/ParameterTrait.php | ParameterTrait.getParameter | public function getParameter($key, $default_value = NULL) {
if (isset($this->params[$key])) {
return $this->params[$key];
}
$defaults = $this->sandbox()
->getPolicy()
->getParameterDefaults();
if (isset($defaults[$key])) {
$default_value = $defaults[$key];
}
// Ensure ... | php | public function getParameter($key, $default_value = NULL) {
if (isset($this->params[$key])) {
return $this->params[$key];
}
$defaults = $this->sandbox()
->getPolicy()
->getParameterDefaults();
if (isset($defaults[$key])) {
$default_value = $defaults[$key];
}
// Ensure ... | [
"public",
"function",
"getParameter",
"(",
"$",
"key",
",",
"$",
"default_value",
"=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"... | Expose parameters to the check. | [
"Expose",
"parameters",
"to",
"the",
"check",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Sandbox/ParameterTrait.php#L18-L34 |
drutiny/drutiny | src/Container.php | Container.getVerbosity | public static function getVerbosity()
{
if (!isset(self::$verbosity)) {
switch (getenv('SHELL_VERBOSITY')) {
case -1: return OutputInterface::VERBOSITY_QUIET; break;
case 1: return OutputInterface::VERBOSITY_VERBOSE; break;
case 2: return OutputInterface::VERBOSITY_VE... | php | public static function getVerbosity()
{
if (!isset(self::$verbosity)) {
switch (getenv('SHELL_VERBOSITY')) {
case -1: return OutputInterface::VERBOSITY_QUIET; break;
case 1: return OutputInterface::VERBOSITY_VERBOSE; break;
case 2: return OutputInterface::VERBOSITY_VE... | [
"public",
"static",
"function",
"getVerbosity",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"verbosity",
")",
")",
"{",
"switch",
"(",
"getenv",
"(",
"'SHELL_VERBOSITY'",
")",
")",
"{",
"case",
"-",
"1",
":",
"return",
"OutputInterf... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Container.php#L72-L84 |
drutiny/drutiny | src/Sandbox/Sandbox.php | Sandbox.run | public function run()
{
$response = new AuditResponse($this->getPolicy());
$watchdog = Container::getLogger();
$watchdog->info('Auditing ' . $this->getPolicy()->get('name'));
try {
// Ensure policy dependencies are met.
foreach ($this->getPolicy()->getDepends() as $dependency) {
/... | php | public function run()
{
$response = new AuditResponse($this->getPolicy());
$watchdog = Container::getLogger();
$watchdog->info('Auditing ' . $this->getPolicy()->get('name'));
try {
// Ensure policy dependencies are met.
foreach ($this->getPolicy()->getDepends() as $dependency) {
/... | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"response",
"=",
"new",
"AuditResponse",
"(",
"$",
"this",
"->",
"getPolicy",
"(",
")",
")",
";",
"$",
"watchdog",
"=",
"Container",
"::",
"getLogger",
"(",
")",
";",
"$",
"watchdog",
"->",
"info",
"("... | Run the check and capture the outcomes. | [
"Run",
"the",
"check",
"and",
"capture",
"the",
"outcomes",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Sandbox/Sandbox.php#L80-L125 |
drutiny/drutiny | src/Sandbox/Sandbox.php | Sandbox.remediate | public function remediate()
{
$response = new AuditResponse($this->getPolicy());
try {
// Do not attempt remediation on checks that don't support it.
if (!($this->getAuditor() instanceof RemediableInterface)) {
throw new \Exception(get_class($this->getAuditor()) . ' is not remediable.');
... | php | public function remediate()
{
$response = new AuditResponse($this->getPolicy());
try {
// Do not attempt remediation on checks that don't support it.
if (!($this->getAuditor() instanceof RemediableInterface)) {
throw new \Exception(get_class($this->getAuditor()) . ' is not remediable.');
... | [
"public",
"function",
"remediate",
"(",
")",
"{",
"$",
"response",
"=",
"new",
"AuditResponse",
"(",
"$",
"this",
"->",
"getPolicy",
"(",
")",
")",
";",
"try",
"{",
"// Do not attempt remediation on checks that don't support it.",
"if",
"(",
"!",
"(",
"$",
"th... | Remediate the check if available. | [
"Remediate",
"the",
"check",
"if",
"available",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Sandbox/Sandbox.php#L130-L151 |
drutiny/drutiny | src/Report/Format.php | Format.renderTemplate | public function renderTemplate($tpl, array $render) {
$registry = new \Drutiny\Registry();
$loader = new \Twig_Loader_Filesystem($registry->templateDirs());
$twig = new \Twig_Environment($loader, array(
'cache' => sys_get_temp_dir() . '/drutiny/cache',
'auto_reload' => TRUE,
// 'debug' => ... | php | public function renderTemplate($tpl, array $render) {
$registry = new \Drutiny\Registry();
$loader = new \Twig_Loader_Filesystem($registry->templateDirs());
$twig = new \Twig_Environment($loader, array(
'cache' => sys_get_temp_dir() . '/drutiny/cache',
'auto_reload' => TRUE,
// 'debug' => ... | [
"public",
"function",
"renderTemplate",
"(",
"$",
"tpl",
",",
"array",
"$",
"render",
")",
"{",
"$",
"registry",
"=",
"new",
"\\",
"Drutiny",
"\\",
"Registry",
"(",
")",
";",
"$",
"loader",
"=",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
"$",
"registry"... | Render an HTML template.
@param string $tpl
The name of the .html.tpl template file to load for rendering.
@param array $render
An array of variables to be used within the template by the rendering engine.
@return string | [
"Render",
"an",
"HTML",
"template",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Report/Format.php#L114-L144 |
drutiny/drutiny | src/Report/Format.php | Format.setOutput | public function setOutput($filepath = 'stdout')
{
if ($filepath != 'stdout' && !($filepath instanceof OutputInterface) && !file_exists(dirname($filepath))) {
throw new \InvalidArgumentException("Cannot write to $filepath. Parent directory doesn't exist.");
}
$this->output = $filepath;
return $th... | php | public function setOutput($filepath = 'stdout')
{
if ($filepath != 'stdout' && !($filepath instanceof OutputInterface) && !file_exists(dirname($filepath))) {
throw new \InvalidArgumentException("Cannot write to $filepath. Parent directory doesn't exist.");
}
$this->output = $filepath;
return $th... | [
"public",
"function",
"setOutput",
"(",
"$",
"filepath",
"=",
"'stdout'",
")",
"{",
"if",
"(",
"$",
"filepath",
"!=",
"'stdout'",
"&&",
"!",
"(",
"$",
"filepath",
"instanceof",
"OutputInterface",
")",
"&&",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"... | Set the title of the profile. | [
"Set",
"the",
"title",
"of",
"the",
"profile",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Report/Format.php#L157-L164 |
drutiny/drutiny | src/AuditResponse/AuditResponse.php | AuditResponse.set | public function set($state = NULL, array $tokens) {
switch (TRUE) {
case ($state === Audit::SUCCESS):
case ($state === Audit::PASS):
$state = Audit::SUCCESS;
break;
case ($state === Audit::FAILURE):
case ($state === Audit::FAIL):
$state = Audit::FAIL;
break;
... | php | public function set($state = NULL, array $tokens) {
switch (TRUE) {
case ($state === Audit::SUCCESS):
case ($state === Audit::PASS):
$state = Audit::SUCCESS;
break;
case ($state === Audit::FAILURE):
case ($state === Audit::FAIL):
$state = Audit::FAIL;
break;
... | [
"public",
"function",
"set",
"(",
"$",
"state",
"=",
"NULL",
",",
"array",
"$",
"tokens",
")",
"{",
"switch",
"(",
"TRUE",
")",
"{",
"case",
"(",
"$",
"state",
"===",
"Audit",
"::",
"SUCCESS",
")",
":",
"case",
"(",
"$",
"state",
"===",
"Audit",
... | Set the state of the response. | [
"Set",
"the",
"state",
"of",
"the",
"response",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/AuditResponse/AuditResponse.php#L44-L75 |
drutiny/drutiny | src/AuditResponse/AuditResponse.php | AuditResponse.getType | public function getType()
{
if ($this->isNotApplicable()) {
return 'not-applicable';
}
if ($this->hasError()) {
return 'error';
}
if ($this->isNotice()) {
return 'notice';
}
if ($this->hasWarning()) {
return 'warning';
}
$policy_type = $this->policy->get('ty... | php | public function getType()
{
if ($this->isNotApplicable()) {
return 'not-applicable';
}
if ($this->hasError()) {
return 'error';
}
if ($this->isNotice()) {
return 'notice';
}
if ($this->hasWarning()) {
return 'warning';
}
$policy_type = $this->policy->get('ty... | [
"public",
"function",
"getType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNotApplicable",
"(",
")",
")",
"{",
"return",
"'not-applicable'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasError",
"(",
")",
")",
"{",
"return",
"'error'",
";",
"}",
... | Get the type of response based on policy type and audit response. | [
"Get",
"the",
"type",
"of",
"response",
"based",
"on",
"policy",
"type",
"and",
"audit",
"response",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/AuditResponse/AuditResponse.php#L118-L137 |
drutiny/drutiny | src/AuditResponse/AuditResponse.php | AuditResponse.getSummary | public function getSummary() {
$summary = [];
switch (TRUE) {
case ($this->state === Audit::NOT_APPLICABLE):
$summary[] = "This policy is not applicable to this site.";
break;
case ($this->state === Audit::ERROR):
$tokens = [
'exception' => isset($this->tokens['exc... | php | public function getSummary() {
$summary = [];
switch (TRUE) {
case ($this->state === Audit::NOT_APPLICABLE):
$summary[] = "This policy is not applicable to this site.";
break;
case ($this->state === Audit::ERROR):
$tokens = [
'exception' => isset($this->tokens['exc... | [
"public",
"function",
"getSummary",
"(",
")",
"{",
"$",
"summary",
"=",
"[",
"]",
";",
"switch",
"(",
"TRUE",
")",
"{",
"case",
"(",
"$",
"this",
"->",
"state",
"===",
"Audit",
"::",
"NOT_APPLICABLE",
")",
":",
"$",
"summary",
"[",
"]",
"=",
"\"Thi... | Get the response based on the state outcome.
@return string
Translated description. | [
"Get",
"the",
"response",
"based",
"on",
"the",
"state",
"outcome",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/AuditResponse/AuditResponse.php#L239-L276 |
drutiny/drutiny | src/Report/ProfileRunMultisiteHTMLReport.php | ProfileRunMultisiteHTMLReport.renderTemplate | public function renderTemplate($tpl, array $render_vars) {
$registry = new Registry();
$loader = new \Twig_Loader_Filesystem($registry->templateDirs());
$twig = new \Twig_Environment($loader, array(
'cache' => sys_get_temp_dir() . '/drutiny/cache',
'auto_reload' => TRUE,
));
// $filter =... | php | public function renderTemplate($tpl, array $render_vars) {
$registry = new Registry();
$loader = new \Twig_Loader_Filesystem($registry->templateDirs());
$twig = new \Twig_Environment($loader, array(
'cache' => sys_get_temp_dir() . '/drutiny/cache',
'auto_reload' => TRUE,
));
// $filter =... | [
"public",
"function",
"renderTemplate",
"(",
"$",
"tpl",
",",
"array",
"$",
"render_vars",
")",
"{",
"$",
"registry",
"=",
"new",
"Registry",
"(",
")",
";",
"$",
"loader",
"=",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
"$",
"registry",
"->",
"templateDir... | Render an HTML template.
@param string $tpl
The name of the .html.tpl template file to load for rendering.
@param array $render_vars
An array of variables to be used within the template by the rendering engine.
@return string | [
"Render",
"an",
"HTML",
"template",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Report/ProfileRunMultisiteHTMLReport.php#L96-L110 |
drutiny/drutiny | src/Policy/ParameterizedContentTrait.php | ParameterizedContentTrait.getParameterDefaults | public function getParameterDefaults()
{
$defaults = [];
foreach ($this->parameters as $name => $info) {
$defaults[$name] = isset($info['default']) ? $info['default'] : null;
}
return $defaults;
} | php | public function getParameterDefaults()
{
$defaults = [];
foreach ($this->parameters as $name => $info) {
$defaults[$name] = isset($info['default']) ? $info['default'] : null;
}
return $defaults;
} | [
"public",
"function",
"getParameterDefaults",
"(",
")",
"{",
"$",
"defaults",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"name",
"=>",
"$",
"info",
")",
"{",
"$",
"defaults",
"[",
"$",
"name",
"]",
"=",
"isset",
... | Pull default values from each parameter. | [
"Pull",
"default",
"values",
"from",
"each",
"parameter",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Policy/ParameterizedContentTrait.php#L29-L36 |
drutiny/drutiny | src/Profile/PolicyDefinition.php | PolicyDefinition.createFromProfile | public static function createFromProfile($name, $weight = 0, $definition = [])
{
$policyDefinition = new static();
$policyDefinition->setName($name)
->setWeight($weight);
if (isset($definition['parameters'])) {
$policyDefinition->setParameters($definition['parameters']);
}
... | php | public static function createFromProfile($name, $weight = 0, $definition = [])
{
$policyDefinition = new static();
$policyDefinition->setName($name)
->setWeight($weight);
if (isset($definition['parameters'])) {
$policyDefinition->setParameters($definition['parameters']);
}
... | [
"public",
"static",
"function",
"createFromProfile",
"(",
"$",
"name",
",",
"$",
"weight",
"=",
"0",
",",
"$",
"definition",
"=",
"[",
"]",
")",
"{",
"$",
"policyDefinition",
"=",
"new",
"static",
"(",
")",
";",
"$",
"policyDefinition",
"->",
"setName",
... | Build a PolicyDefinition from Profile input.
@var $name string
@var $definition array | [
"Build",
"a",
"PolicyDefinition",
"from",
"Profile",
"input",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/PolicyDefinition.php#L44-L70 |
drutiny/drutiny | src/Profile/PolicyDefinition.php | PolicyDefinition.getPolicy | public function getPolicy()
{
$policy = Policy::load($this->getName());
if ($this->getSeverity() !== NULL) {
$policy->setSeverity($this->getSeverity());
}
foreach ($this->parameters as $param => $value) {
$info = ['default' => $value];
$policy->addParameter($param, $info);
}
... | php | public function getPolicy()
{
$policy = Policy::load($this->getName());
if ($this->getSeverity() !== NULL) {
$policy->setSeverity($this->getSeverity());
}
foreach ($this->parameters as $param => $value) {
$info = ['default' => $value];
$policy->addParameter($param, $info);
}
... | [
"public",
"function",
"getPolicy",
"(",
")",
"{",
"$",
"policy",
"=",
"Policy",
"::",
"load",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getSeverity",
"(",
")",
"!==",
"NULL",
")",
"{",
"$",
"policy",
"-... | Get the policy for the profile. | [
"Get",
"the",
"policy",
"for",
"the",
"profile",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/PolicyDefinition.php#L114-L126 |
drutiny/drutiny | src/Profile/PolicyDefinition.php | PolicyDefinition.setDependencyPolicyName | public function setDependencyPolicyName($name)
{
$this->positionBefore[$name] = self::createFromProfile($name, $this->getWeight());
return $this;
} | php | public function setDependencyPolicyName($name)
{
$this->positionBefore[$name] = self::createFromProfile($name, $this->getWeight());
return $this;
} | [
"public",
"function",
"setDependencyPolicyName",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"positionBefore",
"[",
"$",
"name",
"]",
"=",
"self",
"::",
"createFromProfile",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getWeight",
"(",
")",
")",
";",
... | Track a policy dependency as a policy definition. | [
"Track",
"a",
"policy",
"dependency",
"as",
"a",
"policy",
"definition",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/PolicyDefinition.php#L131-L135 |
drutiny/drutiny | src/Driver/DrushRouter.php | DrushRouter.createFromTarget | public static function createFromTarget(TargetInterface $target, $options = [])
{
try {
$info = $target->getOptions();
$launchers = ['drush-launcher', 'drush.launcher', 'drush'];
$binary = 'which ' . implode(' || which ', $launchers);
$info = trim($target->exec('$(' . $binary . ') -r ' . ... | php | public static function createFromTarget(TargetInterface $target, $options = [])
{
try {
$info = $target->getOptions();
$launchers = ['drush-launcher', 'drush.launcher', 'drush'];
$binary = 'which ' . implode(' || which ', $launchers);
$info = trim($target->exec('$(' . $binary . ') -r ' . ... | [
"public",
"static",
"function",
"createFromTarget",
"(",
"TargetInterface",
"$",
"target",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"info",
"=",
"$",
"target",
"->",
"getOptions",
"(",
")",
";",
"$",
"launchers",
"=",
"[",
"'drush... | Derive a drush driver from a given Target. | [
"Derive",
"a",
"drush",
"driver",
"from",
"a",
"given",
"Target",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushRouter.php#L31-L66 |
drutiny/drutiny | src/Profile/ProfileSourceDrutinyGitHubIO.php | ProfileSourceDrutinyGitHubIO.getList | public function getList()
{
$api = new Api();
$list = [];
foreach ($api->getProfileList() as $listedPolicy) {
$list[$listedPolicy['name']] = $listedPolicy;
}
return $list;
} | php | public function getList()
{
$api = new Api();
$list = [];
foreach ($api->getProfileList() as $listedPolicy) {
$list[$listedPolicy['name']] = $listedPolicy;
}
return $list;
} | [
"public",
"function",
"getList",
"(",
")",
"{",
"$",
"api",
"=",
"new",
"Api",
"(",
")",
";",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"api",
"->",
"getProfileList",
"(",
")",
"as",
"$",
"listedPolicy",
")",
"{",
"$",
"list",
"[",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSourceDrutinyGitHubIO.php#L22-L30 |
drutiny/drutiny | src/Profile/ProfileSourceDrutinyGitHubIO.php | ProfileSourceDrutinyGitHubIO.load | public function load(array $definition)
{
$endpoint = str_replace('{baseUri}/api/', '', $definition['_links']['self']['href']);
$info = json_decode(Api::getClient()->get($endpoint)->getBody(), TRUE);
$info['filepath'] = Api::BaseUrl . $endpoint;
$profile = new Profile();
$profile->setTitle($info[... | php | public function load(array $definition)
{
$endpoint = str_replace('{baseUri}/api/', '', $definition['_links']['self']['href']);
$info = json_decode(Api::getClient()->get($endpoint)->getBody(), TRUE);
$info['filepath'] = Api::BaseUrl . $endpoint;
$profile = new Profile();
$profile->setTitle($info[... | [
"public",
"function",
"load",
"(",
"array",
"$",
"definition",
")",
"{",
"$",
"endpoint",
"=",
"str_replace",
"(",
"'{baseUri}/api/'",
",",
"''",
",",
"$",
"definition",
"[",
"'_links'",
"]",
"[",
"'self'",
"]",
"[",
"'href'",
"]",
")",
";",
"$",
"info... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Profile/ProfileSourceDrutinyGitHubIO.php#L35-L79 |
drutiny/drutiny | src/Target/Target.php | Target.parseTarget | static public function parseTarget($target)
{
$target_name = 'drush';
$target_data = $target;
if (strpos($target, ':') !== FALSE) {
list($target_name, $target_data) = explode(':', $target, 2);
}
return [$target_name, $target_data];
} | php | static public function parseTarget($target)
{
$target_name = 'drush';
$target_data = $target;
if (strpos($target, ':') !== FALSE) {
list($target_name, $target_data) = explode(':', $target, 2);
}
return [$target_name, $target_data];
} | [
"static",
"public",
"function",
"parseTarget",
"(",
"$",
"target",
")",
"{",
"$",
"target_name",
"=",
"'drush'",
";",
"$",
"target_data",
"=",
"$",
"target",
";",
"if",
"(",
"strpos",
"(",
"$",
"target",
",",
"':'",
")",
"!==",
"FALSE",
")",
"{",
"li... | Parse a target argument into the target driver and data. | [
"Parse",
"a",
"target",
"argument",
"into",
"the",
"target",
"driver",
"and",
"data",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Target/Target.php#L66-L74 |
drutiny/drutiny | src/Target/Target.php | Target.getMetadata | final public function getMetadata()
{
$item = Container::cache('target')->getItem('metadata');
if (!$item->isHit()) {
$metadata = [];
$reflection = new \ReflectionClass($this);
$interfaces = $reflection->getInterfaces();
$reader = new AnnotationReader();
foreach ($interfaces as... | php | final public function getMetadata()
{
$item = Container::cache('target')->getItem('metadata');
if (!$item->isHit()) {
$metadata = [];
$reflection = new \ReflectionClass($this);
$interfaces = $reflection->getInterfaces();
$reader = new AnnotationReader();
foreach ($interfaces as... | [
"final",
"public",
"function",
"getMetadata",
"(",
")",
"{",
"$",
"item",
"=",
"Container",
"::",
"cache",
"(",
"'target'",
")",
"->",
"getItem",
"(",
"'metadata'",
")",
";",
"if",
"(",
"!",
"$",
"item",
"->",
"isHit",
"(",
")",
")",
"{",
"$",
"met... | Pull metadata from Drutiny\Target\Metadata interfaces.
@return array of metatdata keyed by metadata name. | [
"Pull",
"metadata",
"from",
"Drutiny",
"\\",
"Target",
"\\",
"Metadata",
"interfaces",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Target/Target.php#L89-L112 |
drutiny/drutiny | src/Target/DrushTarget.php | DrushTarget.runDrushCommand | public function runDrushCommand($method, array $args, array $options, $pipe = '', $bin = 'drush') {
$parameters = [
'@method' => $method,
'@args' => implode(' ', $args),
'@options' => implode(' ', $options),
'@alias' => $this->getAlias(),
'@pipe' => $pipe,
'@drush' => $bin,
]... | php | public function runDrushCommand($method, array $args, array $options, $pipe = '', $bin = 'drush') {
$parameters = [
'@method' => $method,
'@args' => implode(' ', $args),
'@options' => implode(' ', $options),
'@alias' => $this->getAlias(),
'@pipe' => $pipe,
'@drush' => $bin,
]... | [
"public",
"function",
"runDrushCommand",
"(",
"$",
"method",
",",
"array",
"$",
"args",
",",
"array",
"$",
"options",
",",
"$",
"pipe",
"=",
"''",
",",
"$",
"bin",
"=",
"'drush'",
")",
"{",
"$",
"parameters",
"=",
"[",
"'@method'",
"=>",
"$",
"method... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Target/DrushTarget.php#L60-L76 |
drutiny/drutiny | src/PolicySource/PolicySource.php | PolicySource.loadPolicyByName | public static function loadPolicyByName($name)
{
$list = self::getPolicyList();
if (!isset($list[$name])) {
$list = self::getPolicyList(TRUE);
if (!isset($list[$name])) {
throw new UnknownPolicyException("$name does not exist.");
}
throw new UnavailablePolicyException("$name r... | php | public static function loadPolicyByName($name)
{
$list = self::getPolicyList();
if (!isset($list[$name])) {
$list = self::getPolicyList(TRUE);
if (!isset($list[$name])) {
throw new UnknownPolicyException("$name does not exist.");
}
throw new UnavailablePolicyException("$name r... | [
"public",
"static",
"function",
"loadPolicyByName",
"(",
"$",
"name",
")",
"{",
"$",
"list",
"=",
"self",
"::",
"getPolicyList",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"list",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"list",
"=",
"se... | Load policy by name.
@param $name string | [
"Load",
"policy",
"by",
"name",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/PolicySource/PolicySource.php#L15-L35 |
drutiny/drutiny | src/PolicySource/PolicySource.php | PolicySource.getPolicyList | public static function getPolicyList($include_invalid = FALSE)
{
static $list, $available_list;
if ($include_invalid && !empty($list)) {
return $list;
}
if (!empty($available_list)) {
return $available_list;
}
$timer = Container::utility()->timer()->start();
Container::getLo... | php | public static function getPolicyList($include_invalid = FALSE)
{
static $list, $available_list;
if ($include_invalid && !empty($list)) {
return $list;
}
if (!empty($available_list)) {
return $available_list;
}
$timer = Container::utility()->timer()->start();
Container::getLo... | [
"public",
"static",
"function",
"getPolicyList",
"(",
"$",
"include_invalid",
"=",
"FALSE",
")",
"{",
"static",
"$",
"list",
",",
"$",
"available_list",
";",
"if",
"(",
"$",
"include_invalid",
"&&",
"!",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"return"... | Acquire a list of available policies.
@return array of policy information arrays. | [
"Acquire",
"a",
"list",
"of",
"available",
"policies",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/PolicySource/PolicySource.php#L42-L76 |
drutiny/drutiny | src/PolicySource/PolicySource.php | PolicySource.loadAll | public static function loadAll()
{
static $list = [];
if (!empty($list)) {
return $list;
}
foreach (self::getPolicyList() as $definition) {
try {
$list[$definition['name']] = self::loadPolicyByName($definition['name']);
}
catch (\Exception $e) {
Container::getLo... | php | public static function loadAll()
{
static $list = [];
if (!empty($list)) {
return $list;
}
foreach (self::getPolicyList() as $definition) {
try {
$list[$definition['name']] = self::loadPolicyByName($definition['name']);
}
catch (\Exception $e) {
Container::getLo... | [
"public",
"static",
"function",
"loadAll",
"(",
")",
"{",
"static",
"$",
"list",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"return",
"$",
"list",
";",
"}",
"foreach",
"(",
"self",
"::",
"getPolicyList",
"(",
")... | Load all policies as loaded Policy objects. | [
"Load",
"all",
"policies",
"as",
"loaded",
"Policy",
"objects",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/PolicySource/PolicySource.php#L81-L96 |
drutiny/drutiny | src/Utility.php | _UtilityTimer.stop | public function stop()
{
$this->end = microtime(true);
return bcsub($this->end, $this->start, 2);
} | php | public function stop()
{
$this->end = microtime(true);
return bcsub($this->end, $this->start, 2);
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"$",
"this",
"->",
"end",
"=",
"microtime",
"(",
"true",
")",
";",
"return",
"bcsub",
"(",
"$",
"this",
"->",
"end",
",",
"$",
"this",
"->",
"start",
",",
"2",
")",
";",
"}"
] | End the timer.
@return int
The number of seconds the timer ran for (rounded). | [
"End",
"the",
"timer",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Utility.php#L52-L56 |
drutiny/drutiny | src/Policy.php | Policy.getParameterDefaults | public function getParameterDefaults()
{
$defaults = $this->useTraitgetParameterDefaults();
$audit = (new Registry)->getAuditMedtadata($this->class);
// Validation. Look for parameters specificed by the policy and not the
// audit.
foreach (array_keys($defaults) as $name) {
if ... | php | public function getParameterDefaults()
{
$defaults = $this->useTraitgetParameterDefaults();
$audit = (new Registry)->getAuditMedtadata($this->class);
// Validation. Look for parameters specificed by the policy and not the
// audit.
foreach (array_keys($defaults) as $name) {
if ... | [
"public",
"function",
"getParameterDefaults",
"(",
")",
"{",
"$",
"defaults",
"=",
"$",
"this",
"->",
"useTraitgetParameterDefaults",
"(",
")",
";",
"$",
"audit",
"=",
"(",
"new",
"Registry",
")",
"->",
"getAuditMedtadata",
"(",
"$",
"this",
"->",
"class",
... | Override ParameterizedContentTrait::getParameterDefaults. | [
"Override",
"ParameterizedContentTrait",
"::",
"getParameterDefaults",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Policy.php#L161-L206 |
drutiny/drutiny | src/PolicySource/LocalFs.php | LocalFs.getList | public function getList()
{
$cache = Container::cache($this->getName())->getItem('list');
if ($cache->isHit()) {
return $cache->get();
}
$finder = Config::getFinder()->name('*.policy.yml');
$list = [];
foreach ($finder as $file) {
$filename = $file->getRelativePathname();
$p... | php | public function getList()
{
$cache = Container::cache($this->getName())->getItem('list');
if ($cache->isHit()) {
return $cache->get();
}
$finder = Config::getFinder()->name('*.policy.yml');
$list = [];
foreach ($finder as $file) {
$filename = $file->getRelativePathname();
$p... | [
"public",
"function",
"getList",
"(",
")",
"{",
"$",
"cache",
"=",
"Container",
"::",
"cache",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"->",
"getItem",
"(",
"'list'",
")",
";",
"if",
"(",
"$",
"cache",
"->",
"isHit",
"(",
")",
")",
"{",... | {@inheritdoc} | [
"{"
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/PolicySource/LocalFs.php#L25-L44 |
drutiny/drutiny | src/Driver/DrushDriver.php | DrushDriver.createFromTarget | public static function createFromTarget(TargetInterface $target, $drush_bin = 'drush')
{
$options = [];
$alias = '@self';
if ($target instanceof DrushTargetInterface) {
$alias = $target->getAlias();
}
return new static($target, $drush_bin, $options, $alias);
} | php | public static function createFromTarget(TargetInterface $target, $drush_bin = 'drush')
{
$options = [];
$alias = '@self';
if ($target instanceof DrushTargetInterface) {
$alias = $target->getAlias();
}
return new static($target, $drush_bin, $options, $alias);
} | [
"public",
"static",
"function",
"createFromTarget",
"(",
"TargetInterface",
"$",
"target",
",",
"$",
"drush_bin",
"=",
"'drush'",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"$",
"alias",
"=",
"'@self'",
";",
"if",
"(",
"$",
"target",
"instanceof",
"Dr... | Instansiate a new Drush Driver instance.
@param TargetInterface $target
@param string $drush_bin path to drush executable. | [
"Instansiate",
"a",
"new",
"Drush",
"Driver",
"instance",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushDriver.php#L52-L60 |
drutiny/drutiny | src/Driver/DrushDriver.php | DrushDriver.runCommand | protected function runCommand($method, $args, $pipe = '') {
// Hand task off to Target directly if it supports it.
if ($this->target instanceof DrushExecutableTargetInterface) {
return $this->target->runDrushCommand($method, $args, $this->getOptions(), $pipe, $this->drushBin);
}
return $this->targ... | php | protected function runCommand($method, $args, $pipe = '') {
// Hand task off to Target directly if it supports it.
if ($this->target instanceof DrushExecutableTargetInterface) {
return $this->target->runDrushCommand($method, $args, $this->getOptions(), $pipe, $this->drushBin);
}
return $this->targ... | [
"protected",
"function",
"runCommand",
"(",
"$",
"method",
",",
"$",
"args",
",",
"$",
"pipe",
"=",
"''",
")",
"{",
"// Hand task off to Target directly if it supports it.",
"if",
"(",
"$",
"this",
"->",
"target",
"instanceof",
"DrushExecutableTargetInterface",
")",... | Run the drush command. | [
"Run",
"the",
"drush",
"command",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushDriver.php#L98-L111 |
drutiny/drutiny | src/Driver/DrushDriver.php | DrushDriver.setOptions | public function setOptions(array $options) {
foreach ($options as $key => $value) {
if (is_int($key)) {
$option = '--' . $value;
}
elseif (strlen($key) == 1) {
$option = '-' . $key;
if (!empty($value)) {
$option .= ' ' . escapeshellarg($value);
}
}
... | php | public function setOptions(array $options) {
foreach ($options as $key => $value) {
if (is_int($key)) {
$option = '--' . $value;
}
elseif (strlen($key) == 1) {
$option = '-' . $key;
if (!empty($value)) {
$option .= ' ' . escapeshellarg($value);
}
}
... | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"option",
"=",
"'--'",
".",
"$",... | Set drush options. | [
"Set",
"drush",
"options",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushDriver.php#L129-L155 |
drutiny/drutiny | src/Driver/DrushDriver.php | DrushDriver.cleanOutput | private function cleanOutput($output) {
if (!is_array($output)) {
$output = explode(PHP_EOL, $output);
}
// Datetime weirdness. Apparently this is caused by theming issues on the
// remote theme. Why it is being called when executed via CLI is another
// story.
foreach ($output as $key =>... | php | private function cleanOutput($output) {
if (!is_array($output)) {
$output = explode(PHP_EOL, $output);
}
// Datetime weirdness. Apparently this is caused by theming issues on the
// remote theme. Why it is being called when executed via CLI is another
// story.
foreach ($output as $key =>... | [
"private",
"function",
"cleanOutput",
"(",
"$",
"output",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"output",
")",
")",
"{",
"$",
"output",
"=",
"explode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
";",
"}",
"// Datetime weirdness. Apparently this is ... | Clean up the output of Drush.
@param $output
@return array | [
"Clean",
"up",
"the",
"output",
"of",
"Drush",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushDriver.php#L163-L191 |
drutiny/drutiny | src/Driver/DrushDriver.php | DrushDriver.moduleEnabled | public function moduleEnabled($name) {
$this->options[] = '--format=json';
$modules = $this->__call('pmList', []);
if (!$modules = json_decode($modules, TRUE)) {
throw new DrushFormatException("Cannot parse json output from drush: $modules", $modules);
}
$this->options = [];
return isset($... | php | public function moduleEnabled($name) {
$this->options[] = '--format=json';
$modules = $this->__call('pmList', []);
if (!$modules = json_decode($modules, TRUE)) {
throw new DrushFormatException("Cannot parse json output from drush: $modules", $modules);
}
$this->options = [];
return isset($... | [
"public",
"function",
"moduleEnabled",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"]",
"=",
"'--format=json'",
";",
"$",
"modules",
"=",
"$",
"this",
"->",
"__call",
"(",
"'pmList'",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"$",... | Determine if a module is enabled or not.
@param $name
The machine name of the module to check.
@return bool
Whether the module is enabled or not.
@throws DrushFormatException | [
"Determine",
"if",
"a",
"module",
"is",
"enabled",
"or",
"not",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushDriver.php#L203-L211 |
drutiny/drutiny | src/Driver/DrushDriver.php | DrushDriver.configSet | public function configSet($collection, $key, $value) {
$value = base64_encode(Yaml::dump($value));
if ($index = array_search('--format=json', $this->options)) {
unset($this->options[$index]);
}
$this->options[] = '--format=yaml';
$this->options[] = '-y';
$pipe = "echo '$value' | base64 -... | php | public function configSet($collection, $key, $value) {
$value = base64_encode(Yaml::dump($value));
if ($index = array_search('--format=json', $this->options)) {
unset($this->options[$index]);
}
$this->options[] = '--format=yaml';
$this->options[] = '-y';
$pipe = "echo '$value' | base64 -... | [
"public",
"function",
"configSet",
"(",
"$",
"collection",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"base64_encode",
"(",
"Yaml",
"::",
"dump",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"index",
"=",
"array_search",
... | Override config-set to allow better value setting.
@param $collection
@param $key
@param $value
@return bool | [
"Override",
"config",
"-",
"set",
"to",
"allow",
"better",
"value",
"setting",
"."
] | train | https://github.com/drutiny/drutiny/blob/ba16557024f36e0f2f1612aae7f35cac9f460d81/src/Driver/DrushDriver.php#L221-L237 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.