repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
OXID-eSales/testing_library
library/MinkWrapper.php
MinkWrapper._getElementByLink
protected function _getElementByLink($sSelector) { $sSelector = str_replace('link=', '', $sSelector); $sParsedSelector = $this->getMinkSession()->getSelectorsHandler()->xpathLiteral($sSelector); $oElements = $this->getMinkSession()->getPage()->findAll('named', array('link', $sParsedSelector)); if (empty($oElements)) { $aSelectorParts = explode(' ', $sSelector); $aSelectorParts = array_map(array($this->getMinkSession()->getSelectorsHandler(), 'xpathLiteral'), $aSelectorParts); $sFormedSelector = "//a[contains(.," . implode(") and contains(.,", $aSelectorParts) . ")]"; $oElements = $this->getMinkSession()->getPage()->findAll('xpath', $sFormedSelector); } return $this->_getExactMatch($oElements, $sSelector); }
php
protected function _getElementByLink($sSelector) { $sSelector = str_replace('link=', '', $sSelector); $sParsedSelector = $this->getMinkSession()->getSelectorsHandler()->xpathLiteral($sSelector); $oElements = $this->getMinkSession()->getPage()->findAll('named', array('link', $sParsedSelector)); if (empty($oElements)) { $aSelectorParts = explode(' ', $sSelector); $aSelectorParts = array_map(array($this->getMinkSession()->getSelectorsHandler(), 'xpathLiteral'), $aSelectorParts); $sFormedSelector = "//a[contains(.," . implode(") and contains(.,", $aSelectorParts) . ")]"; $oElements = $this->getMinkSession()->getPage()->findAll('xpath', $sFormedSelector); } return $this->_getExactMatch($oElements, $sSelector); }
[ "protected", "function", "_getElementByLink", "(", "$", "sSelector", ")", "{", "$", "sSelector", "=", "str_replace", "(", "'link='", ",", "''", ",", "$", "sSelector", ")", ";", "$", "sParsedSelector", "=", "$", "this", "->", "getMinkSession", "(", ")", "->...
Returns element by given link @param string $sSelector @return mixed
[ "Returns", "element", "by", "given", "link" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/MinkWrapper.php#L850-L866
train
OXID-eSales/testing_library
library/Services/ShopObjectConstructor/Constructor/oxListConstructor.php
oxListConstructor.callFunction
public function callFunction($functionName, $parameters) { if ($functionName == 'getList') { $oObject = $this->getObject(); $mResponse = $this->_formArrayFromList($oObject->getList()); } else { $mResponse = parent::callFunction($functionName, $parameters); } return $mResponse; }
php
public function callFunction($functionName, $parameters) { if ($functionName == 'getList') { $oObject = $this->getObject(); $mResponse = $this->_formArrayFromList($oObject->getList()); } else { $mResponse = parent::callFunction($functionName, $parameters); } return $mResponse; }
[ "public", "function", "callFunction", "(", "$", "functionName", ",", "$", "parameters", ")", "{", "if", "(", "$", "functionName", "==", "'getList'", ")", "{", "$", "oObject", "=", "$", "this", "->", "getObject", "(", ")", ";", "$", "mResponse", "=", "$...
Calls object function with given parameters @param string $functionName @param array $parameters @return mixed
[ "Calls", "object", "function", "with", "given", "parameters" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ShopObjectConstructor/Constructor/oxListConstructor.php#L32-L42
train
OXID-eSales/testing_library
library/Services/ShopObjectConstructor/Constructor/oxListConstructor.php
oxListConstructor._formArrayFromList
protected function _formArrayFromList($oList) { $aData = array(); foreach ($oList as $sKey => $object) { $aData[$sKey] = $this->_getObjectFieldValues($object); } return $aData; }
php
protected function _formArrayFromList($oList) { $aData = array(); foreach ($oList as $sKey => $object) { $aData[$sKey] = $this->_getObjectFieldValues($object); } return $aData; }
[ "protected", "function", "_formArrayFromList", "(", "$", "oList", ")", "{", "$", "aData", "=", "array", "(", ")", ";", "foreach", "(", "$", "oList", "as", "$", "sKey", "=>", "$", "object", ")", "{", "$", "aData", "[", "$", "sKey", "]", "=", "$", ...
Returns formed array with data from given list @param \OxidEsales\Eshop\Core\Model\ListModel|Iterator $oList @return array
[ "Returns", "formed", "array", "with", "data", "from", "given", "list" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ShopObjectConstructor/Constructor/oxListConstructor.php#L50-L58
train
OXID-eSales/testing_library
library/Services/ShopObjectConstructor/Constructor/oxListConstructor.php
oxListConstructor._getObjectFieldValues
protected function _getObjectFieldValues($object) { $result = array(); $fields = $object->getFieldNames(); $tableName = $object->getCoreTableName(); foreach ($fields as $field) { $fieldName = $tableName.'__'.$field; $result[$field] = $object->$fieldName->value; } return $result; }
php
protected function _getObjectFieldValues($object) { $result = array(); $fields = $object->getFieldNames(); $tableName = $object->getCoreTableName(); foreach ($fields as $field) { $fieldName = $tableName.'__'.$field; $result[$field] = $object->$fieldName->value; } return $result; }
[ "protected", "function", "_getObjectFieldValues", "(", "$", "object", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "fields", "=", "$", "object", "->", "getFieldNames", "(", ")", ";", "$", "tableName", "=", "$", "object", "->", "getCoreTable...
Returns object field values @param \OxidEsales\Eshop\Core\Model\BaseModel|object $object @return array
[ "Returns", "object", "field", "values" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ShopObjectConstructor/Constructor/oxListConstructor.php#L67-L78
train
OXID-eSales/testing_library
library/Services/ThemeSwitcher/ThemeSwitcher.php
ThemeSwitcher.init
public function init($request) { $themeName = $request->getParameter('themeName'); $shopId = $request->getParameter('shp'); $currentShopId = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId(); \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($shopId); $theme = oxNew( \OxidEsales\Eshop\Core\Theme::class); $theme->load($themeName); $theme->activate(); \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($currentShopId); }
php
public function init($request) { $themeName = $request->getParameter('themeName'); $shopId = $request->getParameter('shp'); $currentShopId = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId(); \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($shopId); $theme = oxNew( \OxidEsales\Eshop\Core\Theme::class); $theme->load($themeName); $theme->activate(); \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($currentShopId); }
[ "public", "function", "init", "(", "$", "request", ")", "{", "$", "themeName", "=", "$", "request", "->", "getParameter", "(", "'themeName'", ")", ";", "$", "shopId", "=", "$", "request", "->", "getParameter", "(", "'shp'", ")", ";", "$", "currentShopId"...
Initiates service. @param \OxidEsales\TestingLibrary\Services\Library\Request $request
[ "Initiates", "service", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ThemeSwitcher/ThemeSwitcher.php#L28-L41
train
OXID-eSales/testing_library
library/ModuleLoader.php
ModuleLoader.activateModules
public function activateModules($modulesToActivate) { $this->clearModuleChain(); // First load all needed config options before the module will be installed. $this->prepareModulesForActivation(); foreach ($modulesToActivate as $modulePath) { $this->installModule($modulePath); } // Reset reverse proxy backend as module activation sets it to flush mode. \OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\Cache\ReverseProxy\ReverseProxyBackend::class, null); }
php
public function activateModules($modulesToActivate) { $this->clearModuleChain(); // First load all needed config options before the module will be installed. $this->prepareModulesForActivation(); foreach ($modulesToActivate as $modulePath) { $this->installModule($modulePath); } // Reset reverse proxy backend as module activation sets it to flush mode. \OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\Cache\ReverseProxy\ReverseProxyBackend::class, null); }
[ "public", "function", "activateModules", "(", "$", "modulesToActivate", ")", "{", "$", "this", "->", "clearModuleChain", "(", ")", ";", "// First load all needed config options before the module will be installed.", "$", "this", "->", "prepareModulesForActivation", "(", ")"...
Loads modules and activates them. @param array $modulesToActivate Array of modules to load.
[ "Loads", "modules", "and", "activates", "them", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/ModuleLoader.php#L42-L54
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.restoreTable
public function restoreTable($table, $restoreColumns = false) { $dumpChecksum = $this->getDumpChecksum(); $currentChecksum = $this->getTableChecksum($table); if ($currentChecksum[$table] === $dumpChecksum[$table]) { return false; } if ($restoreColumns) { $this->restoreColumns($table); } $this->resetTable($table); return true; }
php
public function restoreTable($table, $restoreColumns = false) { $dumpChecksum = $this->getDumpChecksum(); $currentChecksum = $this->getTableChecksum($table); if ($currentChecksum[$table] === $dumpChecksum[$table]) { return false; } if ($restoreColumns) { $this->restoreColumns($table); } $this->resetTable($table); return true; }
[ "public", "function", "restoreTable", "(", "$", "table", ",", "$", "restoreColumns", "=", "false", ")", "{", "$", "dumpChecksum", "=", "$", "this", "->", "getDumpChecksum", "(", ")", ";", "$", "currentChecksum", "=", "$", "this", "->", "getTableChecksum", ...
Restores table records @param string $table Table to restore @param bool $restoreColumns whether to check and restore table columns @return bool whether table had changes
[ "Restores", "table", "records" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L96-L111
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.resetTable
public function resetTable($table) { $data = $this->getDumpData(); $this->executeQuery("TRUNCATE TABLE `$table`"); if (isset($data[$table]["_sql_"])) { $this->executeQuery($data[$table]["_sql_"]); } }
php
public function resetTable($table) { $data = $this->getDumpData(); $this->executeQuery("TRUNCATE TABLE `$table`"); if (isset($data[$table]["_sql_"])) { $this->executeQuery($data[$table]["_sql_"]); } }
[ "public", "function", "resetTable", "(", "$", "table", ")", "{", "$", "data", "=", "$", "this", "->", "getDumpData", "(", ")", ";", "$", "this", "->", "executeQuery", "(", "\"TRUNCATE TABLE `$table`\"", ")", ";", "if", "(", "isset", "(", "$", "data", "...
Drops all table records and adds them back from dump @param string $table
[ "Drops", "all", "table", "records", "and", "adds", "them", "back", "from", "dump" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L119-L127
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.getTableColumns
private function getTableColumns($tables) { $database = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); $columns = array(); foreach ($tables as $table) { $tmp = $database->getAll("SHOW COLUMNS FROM `$table`"); foreach ($tmp as $sub) { $key = $sub['Field']; unset($sub['Field']); $columns[$table][$key] = $sub; } } return $columns; }
php
private function getTableColumns($tables) { $database = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); $columns = array(); foreach ($tables as $table) { $tmp = $database->getAll("SHOW COLUMNS FROM `$table`"); foreach ($tmp as $sub) { $key = $sub['Field']; unset($sub['Field']); $columns[$table][$key] = $sub; } } return $columns; }
[ "private", "function", "getTableColumns", "(", "$", "tables", ")", "{", "$", "database", "=", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "DatabaseProvider", "::", "getMaster", "(", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "DatabaseP...
Returns columns array for given tables. @param array $tables @return array
[ "Returns", "columns", "array", "for", "given", "tables", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L135-L150
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.getTableData
private function getTableData($tables) { $db = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); $data = array(); foreach ($tables as $table) { $data[$table] = array(); $result = $db->select("SELECT * FROM `${table}`"); if ($result && $result->count() > 0) { $rows = array(); while (!$result->EOF) { $rows[] = $result->fields; $result->fetchRow(); } $data[$table]["_sql_"] = $this->getInsertString($rows, $table); } } return $data; }
php
private function getTableData($tables) { $db = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); $data = array(); foreach ($tables as $table) { $data[$table] = array(); $result = $db->select("SELECT * FROM `${table}`"); if ($result && $result->count() > 0) { $rows = array(); while (!$result->EOF) { $rows[] = $result->fields; $result->fetchRow(); } $data[$table]["_sql_"] = $this->getInsertString($rows, $table); } } return $data; }
[ "private", "function", "getTableData", "(", "$", "tables", ")", "{", "$", "db", "=", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "DatabaseProvider", "::", "getMaster", "(", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "DatabaseProvider",...
Returns data for given tables. @param array $tables @return array
[ "Returns", "data", "for", "given", "tables", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L158-L180
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.executeQuery
private function executeQuery($sQuery) { $oDB = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(); $oDB->execute($sQuery); }
php
private function executeQuery($sQuery) { $oDB = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(); $oDB->execute($sQuery); }
[ "private", "function", "executeQuery", "(", "$", "sQuery", ")", "{", "$", "oDB", "=", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "DatabaseProvider", "::", "getMaster", "(", ")", ";", "$", "oDB", "->", "execute", "(", "$", "sQuery", ")", ";"...
executes given query. @param string $sQuery
[ "executes", "given", "query", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L218-L222
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.getInsertString
private function getInsertString($rows, $table) { $columns = array(); $values = array(); foreach ($rows as $row) { if (empty($columns)) { $columns = array_keys($row); } $rowValues = array(); foreach ($row as $entry) { $entry = is_null($entry) ? "NULL" : \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC)->quote($entry); $rowValues[] = $entry; } $values[] = "(". implode(", ", $rowValues).")"; } $query = "INSERT INTO $table "; $query .= "(`".implode("`, `", $columns)."`) VALUES ".implode(", ", $values); return $query; }
php
private function getInsertString($rows, $table) { $columns = array(); $values = array(); foreach ($rows as $row) { if (empty($columns)) { $columns = array_keys($row); } $rowValues = array(); foreach ($row as $entry) { $entry = is_null($entry) ? "NULL" : \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC)->quote($entry); $rowValues[] = $entry; } $values[] = "(". implode(", ", $rowValues).")"; } $query = "INSERT INTO $table "; $query .= "(`".implode("`, `", $columns)."`) VALUES ".implode(", ", $values); return $query; }
[ "private", "function", "getInsertString", "(", "$", "rows", ",", "$", "table", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "if", "(", ...
Creates a insert string to insert the given row into to given table @param array $rows a array of the current row in the db @param string $table the name of the current table @return string a sql insert string for the given row
[ "Creates", "a", "insert", "string", "to", "insert", "the", "given", "row", "into", "to", "given", "table" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L265-L285
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorer.php
DatabaseRestorer.getTableChecksum
private function getTableChecksum($aTables) { $aTables = is_array($aTables) ? $aTables : array($aTables); $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); $sSelect = 'CHECKSUM TABLE `' . implode("`, `", $aTables) . '`'; $aResults = $oDb->getAll($sSelect); $sDbName = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('dbName'); $aChecksum = array(); foreach ($aResults as $aResult) { $sTable = str_replace($sDbName . '.', '', $aResult['Table']); $aChecksum[$sTable] = $aResult['Checksum']; } return $aChecksum; }
php
private function getTableChecksum($aTables) { $aTables = is_array($aTables) ? $aTables : array($aTables); $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); $sSelect = 'CHECKSUM TABLE `' . implode("`, `", $aTables) . '`'; $aResults = $oDb->getAll($sSelect); $sDbName = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('dbName'); $aChecksum = array(); foreach ($aResults as $aResult) { $sTable = str_replace($sDbName . '.', '', $aResult['Table']); $aChecksum[$sTable] = $aResult['Checksum']; } return $aChecksum; }
[ "private", "function", "getTableChecksum", "(", "$", "aTables", ")", "{", "$", "aTables", "=", "is_array", "(", "$", "aTables", ")", "?", "$", "aTables", ":", "array", "(", "$", "aTables", ")", ";", "$", "oDb", "=", "\\", "OxidEsales", "\\", "Eshop", ...
Converts a string to UTF format. @param array|string $aTables @return array
[ "Converts", "a", "string", "to", "UTF", "format", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorer.php#L294-L309
train
OXID-eSales/testing_library
library/Services/Library/FileUploader.php
FileUploader.uploadFile
public function uploadFile($sFileIndex, $sLocation, $blOverwrite = true) { $aFileInfo = $this->_getFileInfo($sFileIndex); if (!$this->_checkFile($aFileInfo)) { throw new Exception("File with index '$sFileIndex' does not exist or error occurred while downloading it"); } return $this->_moveUploadedFile($aFileInfo, $sLocation, $blOverwrite); }
php
public function uploadFile($sFileIndex, $sLocation, $blOverwrite = true) { $aFileInfo = $this->_getFileInfo($sFileIndex); if (!$this->_checkFile($aFileInfo)) { throw new Exception("File with index '$sFileIndex' does not exist or error occurred while downloading it"); } return $this->_moveUploadedFile($aFileInfo, $sLocation, $blOverwrite); }
[ "public", "function", "uploadFile", "(", "$", "sFileIndex", ",", "$", "sLocation", ",", "$", "blOverwrite", "=", "true", ")", "{", "$", "aFileInfo", "=", "$", "this", "->", "_getFileInfo", "(", "$", "sFileIndex", ")", ";", "if", "(", "!", "$", "this", ...
Uploads file to given location. @param string $sFileIndex File index @param string $sLocation Location where to put uploaded file @param bool $blOverwrite Whether to overwrite existing file @throws Exception Throws exception if file with given index does not exist. @return bool Whether upload succeeded
[ "Uploads", "file", "to", "given", "location", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/FileUploader.php#L26-L35
train
OXID-eSales/testing_library
library/Services/Library/DatabaseRestorer/DatabaseRestorerLocal.php
DatabaseRestorerLocal.getDumpFolderPath
private function getDumpFolderPath() { if (is_null($this->tmpFilePath)) { $dumpName = $this->getDumpName(); $databaseName = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('dbName'); $this->tmpFilePath = $this->tempDirectory . '/' . $databaseName . '_dbdump/'. $dumpName .'/'; $this->getFileHandler()->createDirectory($this->tmpFilePath); } return $this->tmpFilePath; }
php
private function getDumpFolderPath() { if (is_null($this->tmpFilePath)) { $dumpName = $this->getDumpName(); $databaseName = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('dbName'); $this->tmpFilePath = $this->tempDirectory . '/' . $databaseName . '_dbdump/'. $dumpName .'/'; $this->getFileHandler()->createDirectory($this->tmpFilePath); } return $this->tmpFilePath; }
[ "private", "function", "getDumpFolderPath", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "tmpFilePath", ")", ")", "{", "$", "dumpName", "=", "$", "this", "->", "getDumpName", "(", ")", ";", "$", "databaseName", "=", "\\", "OxidEsales", ...
Returns dump file path @return string
[ "Returns", "dump", "file", "path" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/Library/DatabaseRestorer/DatabaseRestorerLocal.php#L154-L164
train
OXID-eSales/testing_library
library/helpers/ExceptionLogFileHelper.php
ExceptionLogFileHelper.getExceptionLogFileContent
public function getExceptionLogFileContent() { $fileCreated = false; /** Suppress the warning, which is emitted, if the file does not exist */ if ($fileDoesNotExist = !@file_exists($this->exceptionLogFile)) { $fileCreated = touch($this->exceptionLogFile); } if ($fileDoesNotExist && !$fileCreated) { throw new \OxidEsales\Eshop\Core\Exception\StandardException('Empty file ' . $this->exceptionLogFile . ' could not have been be created'); } $logFileContent = file_get_contents($this->exceptionLogFile); if (false === $logFileContent) { throw new \OxidEsales\Eshop\Core\Exception\StandardException('File ' . $this->exceptionLogFile . ' could not be read'); } return $logFileContent; }
php
public function getExceptionLogFileContent() { $fileCreated = false; /** Suppress the warning, which is emitted, if the file does not exist */ if ($fileDoesNotExist = !@file_exists($this->exceptionLogFile)) { $fileCreated = touch($this->exceptionLogFile); } if ($fileDoesNotExist && !$fileCreated) { throw new \OxidEsales\Eshop\Core\Exception\StandardException('Empty file ' . $this->exceptionLogFile . ' could not have been be created'); } $logFileContent = file_get_contents($this->exceptionLogFile); if (false === $logFileContent) { throw new \OxidEsales\Eshop\Core\Exception\StandardException('File ' . $this->exceptionLogFile . ' could not be read'); } return $logFileContent; }
[ "public", "function", "getExceptionLogFileContent", "(", ")", "{", "$", "fileCreated", "=", "false", ";", "/** Suppress the warning, which is emitted, if the file does not exist */", "if", "(", "$", "fileDoesNotExist", "=", "!", "@", "file_exists", "(", "$", "this", "->...
Return the complete content of the exception log file as a string. @return string Content of the exception log file @throws \OxidEsales\Eshop\Core\Exception\StandardException if log file contend could not be read
[ "Return", "the", "complete", "content", "of", "the", "exception", "log", "file", "as", "a", "string", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/helpers/ExceptionLogFileHelper.php#L45-L63
train
OXID-eSales/testing_library
library/helpers/ExceptionLogFileHelper.php
ExceptionLogFileHelper.getParsedExceptions
public function getParsedExceptions() { $parsedExceptions = []; $exceptions = $this->getExceptionLinesFromLogFile(); foreach ($exceptions as $exception) { $parsedExceptions[] = str_replace('\\\\', '\\', $exception); } return $parsedExceptions; }
php
public function getParsedExceptions() { $parsedExceptions = []; $exceptions = $this->getExceptionLinesFromLogFile(); foreach ($exceptions as $exception) { $parsedExceptions[] = str_replace('\\\\', '\\', $exception); } return $parsedExceptions; }
[ "public", "function", "getParsedExceptions", "(", ")", "{", "$", "parsedExceptions", "=", "[", "]", ";", "$", "exceptions", "=", "$", "this", "->", "getExceptionLinesFromLogFile", "(", ")", ";", "foreach", "(", "$", "exceptions", "as", "$", "exception", ")",...
Return an array of arrays with parsed exception lines @return array
[ "Return", "an", "array", "of", "arrays", "with", "parsed", "exception", "lines" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/helpers/ExceptionLogFileHelper.php#L87-L97
train
OXID-eSales/testing_library
library/helpers/ExceptionLogFileHelper.php
ExceptionLogFileHelper.getExceptionLinesFromLogFile
protected function getExceptionLinesFromLogFile() { $exceptionLogLines = file($this->exceptionLogFile, FILE_IGNORE_NEW_LINES); if (false === $exceptionLogLines) { throw new \OxidEsales\Eshop\Core\Exception\StandardException('File ' . $this->exceptionLogFile . ' could not be read'); } $exceptionEntries = array_filter( $exceptionLogLines, function ($entry) { return false !== strpos($entry, '.ERROR') && false !== strpos($entry, 'Exception'); } ); return $exceptionEntries; }
php
protected function getExceptionLinesFromLogFile() { $exceptionLogLines = file($this->exceptionLogFile, FILE_IGNORE_NEW_LINES); if (false === $exceptionLogLines) { throw new \OxidEsales\Eshop\Core\Exception\StandardException('File ' . $this->exceptionLogFile . ' could not be read'); } $exceptionEntries = array_filter( $exceptionLogLines, function ($entry) { return false !== strpos($entry, '.ERROR') && false !== strpos($entry, 'Exception'); } ); return $exceptionEntries; }
[ "protected", "function", "getExceptionLinesFromLogFile", "(", ")", "{", "$", "exceptionLogLines", "=", "file", "(", "$", "this", "->", "exceptionLogFile", ",", "FILE_IGNORE_NEW_LINES", ")", ";", "if", "(", "false", "===", "$", "exceptionLogLines", ")", "{", "thr...
Return an array, which only contains the lines with information about the exception, not the whole stacktrace @return array @throws \OxidEsales\Eshop\Core\Exception\StandardException
[ "Return", "an", "array", "which", "only", "contains", "the", "lines", "with", "information", "about", "the", "exception", "not", "the", "whole", "stacktrace" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/helpers/ExceptionLogFileHelper.php#L106-L121
train
OXID-eSales/testing_library
library/Services/ShopObjectConstructor/ShopObjectConstructor.php
ShopObjectConstructor.setActiveShop
protected function setActiveShop($shopId) { if ($shopId && $this->getServiceConfig()->getShopEdition() == 'EE') { \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($shopId); } }
php
protected function setActiveShop($shopId) { if ($shopId && $this->getServiceConfig()->getShopEdition() == 'EE') { \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($shopId); } }
[ "protected", "function", "setActiveShop", "(", "$", "shopId", ")", "{", "if", "(", "$", "shopId", "&&", "$", "this", "->", "getServiceConfig", "(", ")", "->", "getShopEdition", "(", ")", "==", "'EE'", ")", "{", "\\", "OxidEsales", "\\", "Eshop", "\\", ...
Switches active shop @param string $shopId
[ "Switches", "active", "shop" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ShopObjectConstructor/ShopObjectConstructor.php#L81-L86
train
OXID-eSales/testing_library
library/Services/ShopObjectConstructor/ShopObjectConstructor.php
ShopObjectConstructor.setActiveLanguage
protected function setActiveLanguage($language) { $languages = \OxidEsales\Eshop\Core\Registry::getLang()->getLanguageIds(); $languageId = array_search($language, $languages); if ($languageId === false) { throw new Exception("Language $language was not found or is not active in shop"); } \OxidEsales\Eshop\Core\Registry::getLang()->setBaseLanguage($languageId); }
php
protected function setActiveLanguage($language) { $languages = \OxidEsales\Eshop\Core\Registry::getLang()->getLanguageIds(); $languageId = array_search($language, $languages); if ($languageId === false) { throw new Exception("Language $language was not found or is not active in shop"); } \OxidEsales\Eshop\Core\Registry::getLang()->setBaseLanguage($languageId); }
[ "protected", "function", "setActiveLanguage", "(", "$", "language", ")", "{", "$", "languages", "=", "\\", "OxidEsales", "\\", "Eshop", "\\", "Core", "\\", "Registry", "::", "getLang", "(", ")", "->", "getLanguageIds", "(", ")", ";", "$", "languageId", "="...
Switches active language @param string $language @throws Exception
[ "Switches", "active", "language" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ShopObjectConstructor/ShopObjectConstructor.php#L95-L103
train
OXID-eSales/testing_library
library/FileCopier.php
FileCopier.copyFiles
public function copyFiles($source, $target, $setPermissions = false) { if (strpos($target, ':') !== false && strpos($target, '@') !== false) { if (is_dir($source)) { $source .= "/."; } $command = "scp -rp " . escapeshellarg($source) . " " . escapeshellarg($target); if ($setPermissions) { $command = "rsync -rp --perms --chmod=u+rwx,g+rwx,o+rwx " . escapeshellarg($source) . " " . escapeshellarg($target); } } else { $command = "cp -frT " . escapeshellarg($source) . " " . escapeshellarg($target); if ($setPermissions) { $command .= " && chmod 777 " . escapeshellarg($target); } } $this->executeCommand($command); }
php
public function copyFiles($source, $target, $setPermissions = false) { if (strpos($target, ':') !== false && strpos($target, '@') !== false) { if (is_dir($source)) { $source .= "/."; } $command = "scp -rp " . escapeshellarg($source) . " " . escapeshellarg($target); if ($setPermissions) { $command = "rsync -rp --perms --chmod=u+rwx,g+rwx,o+rwx " . escapeshellarg($source) . " " . escapeshellarg($target); } } else { $command = "cp -frT " . escapeshellarg($source) . " " . escapeshellarg($target); if ($setPermissions) { $command .= " && chmod 777 " . escapeshellarg($target); } } $this->executeCommand($command); }
[ "public", "function", "copyFiles", "(", "$", "source", ",", "$", "target", ",", "$", "setPermissions", "=", "false", ")", "{", "if", "(", "strpos", "(", "$", "target", ",", "':'", ")", "!==", "false", "&&", "strpos", "(", "$", "target", ",", "'@'", ...
Copy files to shop @param string $source File or directory to copy. @param string $target Path where to copy. @param bool $setPermissions Whether to set given Target permissions to 777.
[ "Copy", "files", "to", "shop" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/FileCopier.php#L24-L41
train
OXID-eSales/testing_library
library/FileCopier.php
FileCopier.createEmptyDirectory
public function createEmptyDirectory($directory) { if (!is_dir($directory)) { mkdir($directory, 0777, true); } else { $this->deleteTree($directory, false); } }
php
public function createEmptyDirectory($directory) { if (!is_dir($directory)) { mkdir($directory, 0777, true); } else { $this->deleteTree($directory, false); } }
[ "public", "function", "createEmptyDirectory", "(", "$", "directory", ")", "{", "if", "(", "!", "is_dir", "(", "$", "directory", ")", ")", "{", "mkdir", "(", "$", "directory", ",", "0777", ",", "true", ")", ";", "}", "else", "{", "$", "this", "->", ...
Creates new directory if it does not exists, if exists - clears its content. @param string $directory
[ "Creates", "new", "directory", "if", "it", "does", "not", "exists", "if", "exists", "-", "clears", "its", "content", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/FileCopier.php#L48-L55
train
OXID-eSales/testing_library
library/FileCopier.php
FileCopier.deleteTree
protected function deleteTree($directory, $removeBaseDir = false) { $files = array_diff(scandir($directory), array('.', '..')); foreach ($files as $file) { (is_dir("$directory/$file")) ? $this->deleteTree("$directory/$file", true) : @unlink("$directory/$file"); } if ($removeBaseDir) { @rmdir($directory); } }
php
protected function deleteTree($directory, $removeBaseDir = false) { $files = array_diff(scandir($directory), array('.', '..')); foreach ($files as $file) { (is_dir("$directory/$file")) ? $this->deleteTree("$directory/$file", true) : @unlink("$directory/$file"); } if ($removeBaseDir) { @rmdir($directory); } }
[ "protected", "function", "deleteTree", "(", "$", "directory", ",", "$", "removeBaseDir", "=", "false", ")", "{", "$", "files", "=", "array_diff", "(", "scandir", "(", "$", "directory", ")", ",", "array", "(", "'.'", ",", "'..'", ")", ")", ";", "foreach...
Deletes given directory content @param string $directory Path to directory. @param bool $removeBaseDir Whether to delete base directory.
[ "Deletes", "given", "directory", "content" ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/FileCopier.php#L63-L73
train
OXID-eSales/testing_library
library/Services/ClearCache/ClearCache.php
ClearCache.init
public function init($request) { $cache = new Cache(); if ($this->getServiceConfig()->getShopEdition() === ServiceConfig::EDITION_ENTERPRISE) { $cache->clearCacheBackend(); if ($request->getParameter('clearVarnish')) { $cache->clearReverseProxyCache(); } } $cache->clearTemporaryDirectory(); }
php
public function init($request) { $cache = new Cache(); if ($this->getServiceConfig()->getShopEdition() === ServiceConfig::EDITION_ENTERPRISE) { $cache->clearCacheBackend(); if ($request->getParameter('clearVarnish')) { $cache->clearReverseProxyCache(); } } $cache->clearTemporaryDirectory(); }
[ "public", "function", "init", "(", "$", "request", ")", "{", "$", "cache", "=", "new", "Cache", "(", ")", ";", "if", "(", "$", "this", "->", "getServiceConfig", "(", ")", "->", "getShopEdition", "(", ")", "===", "ServiceConfig", "::", "EDITION_ENTERPRISE...
Clears shop cache. @param Request $request
[ "Clears", "shop", "cache", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ClearCache/ClearCache.php#L34-L44
train
OXID-eSales/testing_library
library/Services/ShopPreparation/ShopPreparation.php
ShopPreparation.init
public function init($request) { if ($file = $request->getUploadedFile('importSql')) { $databaseHandler = $this->getDatabaseHandler(); $databaseHandler->import($file); } if ($request->getParameter('dumpDB')) { $databaseRestorer = $this->getDatabaseRestorer(); $databaseRestorer->dumpDB($request->getParameter('dump-prefix')); } if ($request->getParameter('restoreDB')) { $databaseRestorer = $this->getDatabaseRestorer(); $databaseRestorer->restoreDB($request->getParameter('dump-prefix')); } }
php
public function init($request) { if ($file = $request->getUploadedFile('importSql')) { $databaseHandler = $this->getDatabaseHandler(); $databaseHandler->import($file); } if ($request->getParameter('dumpDB')) { $databaseRestorer = $this->getDatabaseRestorer(); $databaseRestorer->dumpDB($request->getParameter('dump-prefix')); } if ($request->getParameter('restoreDB')) { $databaseRestorer = $this->getDatabaseRestorer(); $databaseRestorer->restoreDB($request->getParameter('dump-prefix')); } }
[ "public", "function", "init", "(", "$", "request", ")", "{", "if", "(", "$", "file", "=", "$", "request", "->", "getUploadedFile", "(", "'importSql'", ")", ")", "{", "$", "databaseHandler", "=", "$", "this", "->", "getDatabaseHandler", "(", ")", ";", "...
Handles request parameters. @param Request $request
[ "Handles", "request", "parameters", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Services/ShopPreparation/ShopPreparation.php#L47-L63
train
OXID-eSales/testing_library
library/Bootstrap/SeleniumBootstrap.php
SeleniumBootstrap.init
public function init() { parent::init(); define("SHOP_EDITION", ($this->getTestConfig()->getShopEdition() == 'EE') ? 'EE' : 'PE_CE'); $this->prepareScreenShots(); $this->copyTestFilesToShop(); /** @var \OxidEsales\Eshop\Core\Config $config */ $config = oxNew(\OxidEsales\Eshop\Core\Config::class); \OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\Config::class, $config); register_shutdown_function(function () { AcceptanceTestCase::stopMinkSession(); }); }
php
public function init() { parent::init(); define("SHOP_EDITION", ($this->getTestConfig()->getShopEdition() == 'EE') ? 'EE' : 'PE_CE'); $this->prepareScreenShots(); $this->copyTestFilesToShop(); /** @var \OxidEsales\Eshop\Core\Config $config */ $config = oxNew(\OxidEsales\Eshop\Core\Config::class); \OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\Config::class, $config); register_shutdown_function(function () { AcceptanceTestCase::stopMinkSession(); }); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "define", "(", "\"SHOP_EDITION\"", ",", "(", "$", "this", "->", "getTestConfig", "(", ")", "->", "getShopEdition", "(", ")", "==", "'EE'", ")", "?", "'EE'", ":", "'PE...
Initiates shop before testing.
[ "Initiates", "shop", "before", "testing", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Bootstrap/SeleniumBootstrap.php#L20-L36
train
OXID-eSales/testing_library
library/Bootstrap/SeleniumBootstrap.php
SeleniumBootstrap.prepareScreenShots
public function prepareScreenShots() { $screenShotsPath = $this->getTestConfig()->getScreenShotsPath(); if ($screenShotsPath && !is_dir($screenShotsPath)) { mkdir($screenShotsPath, 0777, true); } }
php
public function prepareScreenShots() { $screenShotsPath = $this->getTestConfig()->getScreenShotsPath(); if ($screenShotsPath && !is_dir($screenShotsPath)) { mkdir($screenShotsPath, 0777, true); } }
[ "public", "function", "prepareScreenShots", "(", ")", "{", "$", "screenShotsPath", "=", "$", "this", "->", "getTestConfig", "(", ")", "->", "getScreenShotsPath", "(", ")", ";", "if", "(", "$", "screenShotsPath", "&&", "!", "is_dir", "(", "$", "screenShotsPat...
Creates screenshots directory if it does not exists.
[ "Creates", "screenshots", "directory", "if", "it", "does", "not", "exists", "." ]
b28f560a1c3fa8b273a914e64fecda8fbb6295a5
https://github.com/OXID-eSales/testing_library/blob/b28f560a1c3fa8b273a914e64fecda8fbb6295a5/library/Bootstrap/SeleniumBootstrap.php#L41-L47
train
amphp/websocket-server
src/Websocket.php
Websocket.multicast
final public function multicast(string $data, array $clientIds): Promise { return $this->multicastData($data, false, $clientIds); }
php
final public function multicast(string $data, array $clientIds): Promise { return $this->multicastData($data, false, $clientIds); }
[ "final", "public", "function", "multicast", "(", "string", "$", "data", ",", "array", "$", "clientIds", ")", ":", "Promise", "{", "return", "$", "this", "->", "multicastData", "(", "$", "data", ",", "false", ",", "$", "clientIds", ")", ";", "}" ]
Send a UTF-8 text message to a set of clients. @param string $data Data to send. @param string[] $clientIds Array of client IDs. @return \Amp\Promise<int>
[ "Send", "a", "UTF", "-", "8", "text", "message", "to", "a", "set", "of", "clients", "." ]
eb666a3546ab90588064a65fd07656bb7b8f662d
https://github.com/amphp/websocket-server/blob/eb666a3546ab90588064a65fd07656bb7b8f662d/src/Websocket.php#L344-L347
train
amphp/websocket-server
src/Websocket.php
Websocket.multicastBinary
final public function multicastBinary(string $data, array $clientIds): Promise { return $this->multicastData($data, true, $clientIds); }
php
final public function multicastBinary(string $data, array $clientIds): Promise { return $this->multicastData($data, true, $clientIds); }
[ "final", "public", "function", "multicastBinary", "(", "string", "$", "data", ",", "array", "$", "clientIds", ")", ":", "Promise", "{", "return", "$", "this", "->", "multicastData", "(", "$", "data", ",", "true", ",", "$", "clientIds", ")", ";", "}" ]
Send a binary message to a set of clients. @param string $data Data to send. @param string[] $clientIds Array of client IDs. @return \Amp\Promise<int>
[ "Send", "a", "binary", "message", "to", "a", "set", "of", "clients", "." ]
eb666a3546ab90588064a65fd07656bb7b8f662d
https://github.com/amphp/websocket-server/blob/eb666a3546ab90588064a65fd07656bb7b8f662d/src/Websocket.php#L370-L373
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Utils/Json.php
Json.encode
public static function encode($array, $options = null) { $result = false; $highPrecisionFloatMap = static::getHighPrecisionFloatMap($array); if (version_compare(PHP_VERSION, '5.4', '>=')) { $jsonOptions = JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES; if (!empty($options)) { foreach ($options as $o) { $jsonOptions += $o; } } $result = json_encode($array, (int)$jsonOptions); } else { $result = json_encode($array); // Unicode fix: http://stackoverflow.com/a/2934602 $result = preg_replace_callback( '/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $result ); // Escaped slashes fix $result = str_replace('\/', '/', $result); } foreach($highPrecisionFloatMap as $scientificValueString => $floatValueString) { // Replace all scientific values by equivalent floatValues $result = str_ireplace($scientificValueString, $floatValueString, $result); } return $result; }
php
public static function encode($array, $options = null) { $result = false; $highPrecisionFloatMap = static::getHighPrecisionFloatMap($array); if (version_compare(PHP_VERSION, '5.4', '>=')) { $jsonOptions = JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES; if (!empty($options)) { foreach ($options as $o) { $jsonOptions += $o; } } $result = json_encode($array, (int)$jsonOptions); } else { $result = json_encode($array); // Unicode fix: http://stackoverflow.com/a/2934602 $result = preg_replace_callback( '/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $result ); // Escaped slashes fix $result = str_replace('\/', '/', $result); } foreach($highPrecisionFloatMap as $scientificValueString => $floatValueString) { // Replace all scientific values by equivalent floatValues $result = str_ireplace($scientificValueString, $floatValueString, $result); } return $result; }
[ "public", "static", "function", "encode", "(", "$", "array", ",", "$", "options", "=", "null", ")", "{", "$", "result", "=", "false", ";", "$", "highPrecisionFloatMap", "=", "static", "::", "getHighPrecisionFloatMap", "(", "$", "array", ")", ";", "if", "...
Encodes a PHP array into a JSON string. Has settings to unescape both slashes and unicode characters. @param array $array Value to convert to JSON @return string JSON encoded string
[ "Encodes", "a", "PHP", "array", "into", "a", "JSON", "string", ".", "Has", "settings", "to", "unescape", "both", "slashes", "and", "unicode", "characters", "." ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Utils/Json.php#L48-L81
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Utils/Json.php
Json.getFromFile
public static function getFromFile($path, $decode = false, $assoc = true) { if (is_readable($path)) { $json = utf8_encode(file_get_contents($path)); if ($decode) { $json = json_decode($json, $assoc); } return $json; } return false; }
php
public static function getFromFile($path, $decode = false, $assoc = true) { if (is_readable($path)) { $json = utf8_encode(file_get_contents($path)); if ($decode) { $json = json_decode($json, $assoc); } return $json; } return false; }
[ "public", "static", "function", "getFromFile", "(", "$", "path", ",", "$", "decode", "=", "false", ",", "$", "assoc", "=", "true", ")", "{", "if", "(", "is_readable", "(", "$", "path", ")", ")", "{", "$", "json", "=", "utf8_encode", "(", "file_get_co...
Trying to open a file and read json from there @param string $path path to the resource @param boolean $decode whether to decode @param boolean $assoc whether to decode to associative array @return mixed json string, json object, json array or false on failure
[ "Trying", "to", "open", "a", "file", "and", "read", "json", "from", "there" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Utils/Json.php#L90-L100
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Utils/Json.php
Json.getHighPrecisionFloatMap
private static function getHighPrecisionFloatMap($value) { if (!is_array($value)) { return static::getFloatMap($value); } $floatMap = []; foreach ($value as $entry) { $floatMap = array_merge(static::getHighPrecisionFloatMap($entry), $floatMap); } return $floatMap; }
php
private static function getHighPrecisionFloatMap($value) { if (!is_array($value)) { return static::getFloatMap($value); } $floatMap = []; foreach ($value as $entry) { $floatMap = array_merge(static::getHighPrecisionFloatMap($entry), $floatMap); } return $floatMap; }
[ "private", "static", "function", "getHighPrecisionFloatMap", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "static", "::", "getFloatMap", "(", "$", "value", ")", ";", "}", "$", "floatMap", "=", "["...
This function builds up a map of float values in scientific notation and the equivalent float notations. json_encode encodes float values in scientific notation, but we want to make sure they are in float notation @param $value the $json to be encoded @return array mapping scientific values to float values
[ "This", "function", "builds", "up", "a", "map", "of", "float", "values", "in", "scientific", "notation", "and", "the", "equivalent", "float", "notations", ".", "json_encode", "encodes", "float", "values", "in", "scientific", "notation", "but", "we", "want", "t...
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Utils/Json.php#L122-L133
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Utils/Json.php
Json.getFloatMap
private static function getFloatMap($value) { if (!is_float($value)) { return []; } $stringValue = json_encode($value); // If the string value is in scientific notation it should have a negative exponent. Split it there. $explodedValue = explode('E-', strtoupper($stringValue)); if (count($explodedValue) === 2) { // The second entry tells us how many decimal places are created via the exponent $decimalsFromExponent = (int)$explodedValue[1]; // The base hase the form x.xxxxx where x is any digit. We need to get the number of decimals after // the dot $decimalsFromBase = 0; $explodedBase = explode('.', $explodedValue[0]); if (count($explodedBase) === 2) { $decimalsFromBase = strlen($explodedBase[1]); } $totalDecimals = $decimalsFromBase + $decimalsFromExponent; $stringValueAsFloat = number_format($value, $totalDecimals); return [ $stringValue => $stringValueAsFloat ]; } return []; }
php
private static function getFloatMap($value) { if (!is_float($value)) { return []; } $stringValue = json_encode($value); // If the string value is in scientific notation it should have a negative exponent. Split it there. $explodedValue = explode('E-', strtoupper($stringValue)); if (count($explodedValue) === 2) { // The second entry tells us how many decimal places are created via the exponent $decimalsFromExponent = (int)$explodedValue[1]; // The base hase the form x.xxxxx where x is any digit. We need to get the number of decimals after // the dot $decimalsFromBase = 0; $explodedBase = explode('.', $explodedValue[0]); if (count($explodedBase) === 2) { $decimalsFromBase = strlen($explodedBase[1]); } $totalDecimals = $decimalsFromBase + $decimalsFromExponent; $stringValueAsFloat = number_format($value, $totalDecimals); return [ $stringValue => $stringValueAsFloat ]; } return []; }
[ "private", "static", "function", "getFloatMap", "(", "$", "value", ")", "{", "if", "(", "!", "is_float", "(", "$", "value", ")", ")", "{", "return", "[", "]", ";", "}", "$", "stringValue", "=", "json_encode", "(", "$", "value", ")", ";", "// If the s...
Helper function to build up the float map @param $value @return array
[ "Helper", "function", "to", "build", "up", "the", "float", "map" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Utils/Json.php#L141-L169
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/DataApi.php
DataApi.request
public function request($endpoint, $securityPacket, $secret, /* FIXME: array */ $requestPacket = [], $action = null) { if (!is_array($requestPacket)) { Init::warnDeprecated( __CLASS__ . '::' . __FUNCTION__ . ':' . ' $requestPacket should be a PHP array.' ); } $init = new Init('data', $securityPacket, $secret, $requestPacket, $action); $params = $init->generate(); return $this->remote->post($endpoint, $params, $this->remoteOptions); }
php
public function request($endpoint, $securityPacket, $secret, /* FIXME: array */ $requestPacket = [], $action = null) { if (!is_array($requestPacket)) { Init::warnDeprecated( __CLASS__ . '::' . __FUNCTION__ . ':' . ' $requestPacket should be a PHP array.' ); } $init = new Init('data', $securityPacket, $secret, $requestPacket, $action); $params = $init->generate(); return $this->remote->post($endpoint, $params, $this->remoteOptions); }
[ "public", "function", "request", "(", "$", "endpoint", ",", "$", "securityPacket", ",", "$", "secret", ",", "/* FIXME: array */", "$", "requestPacket", "=", "[", "]", ",", "$", "action", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "req...
Makes a single request to the data api @param string $endpoint URL to send the request @param array $securityPacket Security details @param string $secret Private key @param array $requestPacket Request packet @param string $action Action for the request @return Remote Instance of the Remote class, the response can be obtained with the getBody() method
[ "Makes", "a", "single", "request", "to", "the", "data", "api" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/DataApi.php#L45-L57
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/DataApi.php
DataApi.requestRecursive
public function requestRecursive($endpoint, $securityPacket, $secret, /* FIXME: array */ $requestPacket = [], $action = null, $callback = null) { $response = array(); if (!is_array($requestPacket)) { Init::warnDeprecated( __CLASS__ . '::' . __FUNCTION__ . ':' . ' $requestPacket should be a PHP array.' ); } do { $request = $this->request($endpoint, $securityPacket, $secret, $requestPacket, $action); $data = Json::isJson($request->getBody()) ? json_decode($request->getBody(), true) : $request->getBody(); if ($data['meta']['status'] === true) { if (!empty($callback) && is_callable($callback)) { call_user_func($callback, $data); } else { $response = array_merge($response, $data['data']); } } else { throw new Exception(Json::encode($data)); } if (array_key_exists('next', $data['meta']) && !empty($data['data'])) { $requestPacket['next'] = $data['meta']['next']; } else { unset($requestPacket['next']); } } while (array_key_exists('next', $requestPacket)); return $response; }
php
public function requestRecursive($endpoint, $securityPacket, $secret, /* FIXME: array */ $requestPacket = [], $action = null, $callback = null) { $response = array(); if (!is_array($requestPacket)) { Init::warnDeprecated( __CLASS__ . '::' . __FUNCTION__ . ':' . ' $requestPacket should be a PHP array.' ); } do { $request = $this->request($endpoint, $securityPacket, $secret, $requestPacket, $action); $data = Json::isJson($request->getBody()) ? json_decode($request->getBody(), true) : $request->getBody(); if ($data['meta']['status'] === true) { if (!empty($callback) && is_callable($callback)) { call_user_func($callback, $data); } else { $response = array_merge($response, $data['data']); } } else { throw new Exception(Json::encode($data)); } if (array_key_exists('next', $data['meta']) && !empty($data['data'])) { $requestPacket['next'] = $data['meta']['next']; } else { unset($requestPacket['next']); } } while (array_key_exists('next', $requestPacket)); return $response; }
[ "public", "function", "requestRecursive", "(", "$", "endpoint", ",", "$", "securityPacket", ",", "$", "secret", ",", "/* FIXME: array */", "$", "requestPacket", "=", "[", "]", ",", "$", "action", "=", "null", ",", "$", "callback", "=", "null", ")", "{", ...
Makes a recursive request to the data api, dependant on whether 'next' is returned in the meta object @param string $endpoint URL to send the request @param array $securityPacket Security details @param string $secret Private key @param array $requestPacket Request packet @param string $action Action for the request @param mixed $callback Optional callback to execute instead of returning data @return array Array of all data requests or [] or using a callback
[ "Makes", "a", "recursive", "request", "to", "the", "data", "api", "dependant", "on", "whether", "next", "is", "returned", "in", "the", "meta", "object" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/DataApi.php#L71-L102
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/Remote.php
Remote.normalizeRequestHeaders
private function normalizeRequestHeaders(array $headers) { // Explicitly set an empty Expect header, so that the server will not // respond with a "100 Continue" status code for large uploads. $emptyExpectHeader = 'Expect: '; $haveExpectHeader = false; for ($i = 0; $i < count($headers); $i++) { if ($this->isExpectHeader($headers[$i])) { // There is already an expect header - let's set it to empty $headers[$i] = $emptyExpectHeader; $haveExpectHeader = true; break; } } if (!$haveExpectHeader) { // There is no expect header - let's add one $headers[] = $emptyExpectHeader; } return $headers; }
php
private function normalizeRequestHeaders(array $headers) { // Explicitly set an empty Expect header, so that the server will not // respond with a "100 Continue" status code for large uploads. $emptyExpectHeader = 'Expect: '; $haveExpectHeader = false; for ($i = 0; $i < count($headers); $i++) { if ($this->isExpectHeader($headers[$i])) { // There is already an expect header - let's set it to empty $headers[$i] = $emptyExpectHeader; $haveExpectHeader = true; break; } } if (!$haveExpectHeader) { // There is no expect header - let's add one $headers[] = $emptyExpectHeader; } return $headers; }
[ "private", "function", "normalizeRequestHeaders", "(", "array", "$", "headers", ")", "{", "// Explicitly set an empty Expect header, so that the server will not", "// respond with a \"100 Continue\" status code for large uploads.", "$", "emptyExpectHeader", "=", "'Expect: '", ";", "$...
Normalize the headers to be used for a request. @param array $headers - the array of headers. Each element is a string. @return array
[ "Normalize", "the", "headers", "to", "be", "used", "for", "a", "request", "." ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/Remote.php#L73-L95
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/Remote.php
Remote.request
private function request($url, $post = false, $options = array()) { $defaults = array( 'connect_timeout' => 10, 'timeout' => 40, 'headers' => array(), 'encoding' => 'utf-8', 'ssl_verify' => true ); $options = array_merge($defaults, $options); // normalize the headers $options['headers'] = $this->normalizeRequestHeaders($options['headers']); $ch = curl_init(); $params = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => $options['encoding'], CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => $options['connect_timeout'], CURLOPT_TIMEOUT => $options['timeout'], CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => $options['ssl_verify'] ); if (!empty($options['headers'])) { $params[CURLOPT_HTTPHEADER] = $options['headers']; } if (!empty($post)) { $params[CURLOPT_POST] = true; $params[CURLOPT_POSTFIELDS] = $post; } curl_setopt_array($ch, $params); $body = curl_exec($ch); $error_code = curl_errno($ch); $error_message = curl_error($ch); $response = curl_getinfo($ch); curl_close($ch); $response['error_code'] = $error_code; $response['error_message'] = $error_message; $response['body'] = $body; $this->result = $response; }
php
private function request($url, $post = false, $options = array()) { $defaults = array( 'connect_timeout' => 10, 'timeout' => 40, 'headers' => array(), 'encoding' => 'utf-8', 'ssl_verify' => true ); $options = array_merge($defaults, $options); // normalize the headers $options['headers'] = $this->normalizeRequestHeaders($options['headers']); $ch = curl_init(); $params = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => $options['encoding'], CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => $options['connect_timeout'], CURLOPT_TIMEOUT => $options['timeout'], CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => $options['ssl_verify'] ); if (!empty($options['headers'])) { $params[CURLOPT_HTTPHEADER] = $options['headers']; } if (!empty($post)) { $params[CURLOPT_POST] = true; $params[CURLOPT_POSTFIELDS] = $post; } curl_setopt_array($ch, $params); $body = curl_exec($ch); $error_code = curl_errno($ch); $error_message = curl_error($ch); $response = curl_getinfo($ch); curl_close($ch); $response['error_code'] = $error_code; $response['error_message'] = $error_message; $response['body'] = $body; $this->result = $response; }
[ "private", "function", "request", "(", "$", "url", ",", "$", "post", "=", "false", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "defaults", "=", "array", "(", "'connect_timeout'", "=>", "10", ",", "'timeout'", "=>", "40", ",", "'header...
Makes a cURL request to an endpoint with an optional request payload and cURL options. @param string $url Full URL of where to POST the request @param array $request Payload of request @param bool $options Optional Curl options @return void
[ "Makes", "a", "cURL", "request", "to", "an", "endpoint", "with", "an", "optional", "request", "payload", "and", "cURL", "options", "." ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/Remote.php#L106-L158
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/Remote.php
Remote.getHeader
public function getHeader($type = 'content_type') { return (array_key_exists($type, $this->result)) ? $this->result[$type] : null; }
php
public function getHeader($type = 'content_type') { return (array_key_exists($type, $this->result)) ? $this->result[$type] : null; }
[ "public", "function", "getHeader", "(", "$", "type", "=", "'content_type'", ")", "{", "return", "(", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "result", ")", ")", "?", "$", "this", "->", "result", "[", "$", "type", "]", ":", "null...
Returns part of the response headers @param string $type Which key in the headers packet to return @return string Header from the response packet
[ "Returns", "part", "of", "the", "response", "headers" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/Remote.php#L191-L194
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/Remote.php
Remote.getSize
public function getSize($format = true) { if ($format) { return Conversion::formatSizeUnits($this->result['size_download']); } return $this->result['size_download']; }
php
public function getSize($format = true) { if ($format) { return Conversion::formatSizeUnits($this->result['size_download']); } return $this->result['size_download']; }
[ "public", "function", "getSize", "(", "$", "format", "=", "true", ")", "{", "if", "(", "$", "format", ")", "{", "return", "Conversion", "::", "formatSizeUnits", "(", "$", "this", "->", "result", "[", "'size_download'", "]", ")", ";", "}", "return", "$"...
Returns the size in bytes of the request body @return mixed Formatted string or raw float (bytes)
[ "Returns", "the", "size", "in", "bytes", "of", "the", "request", "body" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/Remote.php#L201-L207
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Request/Init.php
Init.validate
public function validate($service, &$securityPacket, $secret, $requestPacket, $action) { if (empty($service)) { throw new ValidationException('The `service` argument wasn\'t found or was empty'); } elseif (!in_array(strtolower($service), $this->validServices)) { throw new ValidationException("The service provided ($service) is not valid"); } // In case the user gave us a JSON securityPacket, convert to an array if (!is_array($securityPacket) && is_string($securityPacket)) { $securityPacket = json_decode($securityPacket, true); } if (empty($securityPacket) || !is_array($securityPacket)) { throw new ValidationException('The security packet must be an array'); } else { foreach (array_keys($securityPacket) as $key) { if (!in_array($key, $this->validSecurityKeys)) { throw new ValidationException('Invalid key found in the security packet: ' . $key); } } if ($service === "questions" && !array_key_exists('user_id', $securityPacket)) { throw new ValidationException('Questions API requires a `user_id` in the security packet'); } if (!array_key_exists('timestamp', $securityPacket)) { $securityPacket['timestamp'] = gmdate('Ymd-Hi'); } } if (empty($secret) || !is_string($secret)) { throw new ValidationException('The `secret` argument must be a valid string'); } if (!empty($requestPacket) && !is_array($requestPacket)) { throw new ValidationException('The request packet must be an array or a valid JSON string'); } if (!empty($action) && !is_string($action)) { throw new ValidationException('The `action` argument must be a string'); } }
php
public function validate($service, &$securityPacket, $secret, $requestPacket, $action) { if (empty($service)) { throw new ValidationException('The `service` argument wasn\'t found or was empty'); } elseif (!in_array(strtolower($service), $this->validServices)) { throw new ValidationException("The service provided ($service) is not valid"); } // In case the user gave us a JSON securityPacket, convert to an array if (!is_array($securityPacket) && is_string($securityPacket)) { $securityPacket = json_decode($securityPacket, true); } if (empty($securityPacket) || !is_array($securityPacket)) { throw new ValidationException('The security packet must be an array'); } else { foreach (array_keys($securityPacket) as $key) { if (!in_array($key, $this->validSecurityKeys)) { throw new ValidationException('Invalid key found in the security packet: ' . $key); } } if ($service === "questions" && !array_key_exists('user_id', $securityPacket)) { throw new ValidationException('Questions API requires a `user_id` in the security packet'); } if (!array_key_exists('timestamp', $securityPacket)) { $securityPacket['timestamp'] = gmdate('Ymd-Hi'); } } if (empty($secret) || !is_string($secret)) { throw new ValidationException('The `secret` argument must be a valid string'); } if (!empty($requestPacket) && !is_array($requestPacket)) { throw new ValidationException('The request packet must be an array or a valid JSON string'); } if (!empty($action) && !is_string($action)) { throw new ValidationException('The `action` argument must be a string'); } }
[ "public", "function", "validate", "(", "$", "service", ",", "&", "$", "securityPacket", ",", "$", "secret", ",", "$", "requestPacket", ",", "$", "action", ")", "{", "if", "(", "empty", "(", "$", "service", ")", ")", "{", "throw", "new", "ValidationExce...
Validate the arguments passed to the constructor @param string $service @param array $securityPacket @param string $secret @param array $requestPacket @param string $action
[ "Validate", "the", "arguments", "passed", "to", "the", "constructor" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Request/Init.php#L435-L476
train
Learnosity/learnosity-sdk-php
src/LearnositySdk/Utils/Conversion.php
Conversion.formatSizeUnits
public static function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes === 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; }
php
public static function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes === 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; }
[ "public", "static", "function", "formatSizeUnits", "(", "$", "bytes", ")", "{", "if", "(", "$", "bytes", ">=", "1073741824", ")", "{", "$", "bytes", "=", "number_format", "(", "$", "bytes", "/", "1073741824", ",", "2", ")", ".", "' GB'", ";", "}", "e...
Converts a raw value in bytes to a friendly format. Either Bytes, KB, MB or GB @param int $bytes Raw value to convert @return string
[ "Converts", "a", "raw", "value", "in", "bytes", "to", "a", "friendly", "format", ".", "Either", "Bytes", "KB", "MB", "or", "GB" ]
5bcb69d2d099808cab5ef8fb87c9de27b9be27ed
https://github.com/Learnosity/learnosity-sdk-php/blob/5bcb69d2d099808cab5ef8fb87c9de27b9be27ed/src/LearnositySdk/Utils/Conversion.php#L14-L31
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserListModel.php
UserListModel.getAllInfo
private function getAllInfo() { $data = []; $offset = 0; while (true) { $url = $this->_myAnimeListUrl.'/'.$this->_type.'list/'.$this->_user.'/load.json?offset='.$offset.'&status='.$this->_status; $content = json_decode(file_get_contents($url), true); if ($content) { $count = count($content); for ($i = 0; $i < $count; $i++) { if (!empty($content[$i]['anime_image_path'])) { $content[$i]['anime_image_path'] = Helper::imageUrlCleaner($content[$i]['anime_image_path']); } else { $content[$i]['manga_image_path'] = Helper::imageUrlCleaner($content[$i]['manga_image_path']); } } $data = array_merge($data, $content); $offset += 300; } else { break; } } return $data; }
php
private function getAllInfo() { $data = []; $offset = 0; while (true) { $url = $this->_myAnimeListUrl.'/'.$this->_type.'list/'.$this->_user.'/load.json?offset='.$offset.'&status='.$this->_status; $content = json_decode(file_get_contents($url), true); if ($content) { $count = count($content); for ($i = 0; $i < $count; $i++) { if (!empty($content[$i]['anime_image_path'])) { $content[$i]['anime_image_path'] = Helper::imageUrlCleaner($content[$i]['anime_image_path']); } else { $content[$i]['manga_image_path'] = Helper::imageUrlCleaner($content[$i]['manga_image_path']); } } $data = array_merge($data, $content); $offset += 300; } else { break; } } return $data; }
[ "private", "function", "getAllInfo", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "offset", "=", "0", ";", "while", "(", "true", ")", "{", "$", "url", "=", "$", "this", "->", "_myAnimeListUrl", ".", "'/'", ".", "$", "this", "->", "_type",...
Get user list. @return array
[ "Get", "user", "list", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserListModel.php#L77-L105
train
rl404/MAL-Scraper
src/MalScraper/Model/Top/TopPeopleModel.php
TopPeopleModel.getJapaneseName
private function getJapaneseName($name_area) { $name = $name_area->find('.information', 0)->find('span', 0); if ($name) { $name = $name->plaintext; return substr($name, 1, strlen($name) - 3); } return ''; }
php
private function getJapaneseName($name_area) { $name = $name_area->find('.information', 0)->find('span', 0); if ($name) { $name = $name->plaintext; return substr($name, 1, strlen($name) - 3); } return ''; }
[ "private", "function", "getJapaneseName", "(", "$", "name_area", ")", "{", "$", "name", "=", "$", "name_area", "->", "find", "(", "'.information'", ",", "0", ")", "->", "find", "(", "'span'", ",", "0", ")", ";", "if", "(", "$", "name", ")", "{", "$...
Get japanese name. @param \simplehtmldom_1_5\simple_html_dom $name_area @return string
[ "Get", "japanese", "name", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Top/TopPeopleModel.php#L102-L112
train
rl404/MAL-Scraper
src/MalScraper/Model/Top/TopPeopleModel.php
TopPeopleModel.getBirthday
private function getBirthday($each_char) { $day = $each_char->find('.birthday', 0)->plaintext; $day = preg_replace('/\s+/', ' ', $day); $day = trim($day); return $day == 'Unknown' ? '' : $day; }
php
private function getBirthday($each_char) { $day = $each_char->find('.birthday', 0)->plaintext; $day = preg_replace('/\s+/', ' ', $day); $day = trim($day); return $day == 'Unknown' ? '' : $day; }
[ "private", "function", "getBirthday", "(", "$", "each_char", ")", "{", "$", "day", "=", "$", "each_char", "->", "find", "(", "'.birthday'", ",", "0", ")", "->", "plaintext", ";", "$", "day", "=", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "$", ...
Get birthday. @param \simplehtmldom_1_5\simple_html_dom $each_char @return string
[ "Get", "birthday", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Top/TopPeopleModel.php#L135-L142
train
rl404/MAL-Scraper
src/MalScraper/Model/MainModel.php
MainModel.getHeader
public static function getHeader($url) { $file_headers = @get_headers($url); if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { return 404; } if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 403 Forbidden') { return 403; } return 200; }
php
public static function getHeader($url) { $file_headers = @get_headers($url); if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { return 404; } if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 403 Forbidden') { return 403; } return 200; }
[ "public", "static", "function", "getHeader", "(", "$", "url", ")", "{", "$", "file_headers", "=", "@", "get_headers", "(", "$", "url", ")", ";", "if", "(", "empty", "(", "$", "file_headers", ")", "||", "$", "file_headers", "[", "0", "]", "==", "'HTTP...
Get URL header. @param string $url URL of full MyAnimeList page @return int
[ "Get", "URL", "header", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/MainModel.php#L58-L70
train
rl404/MAL-Scraper
src/MalScraper/Model/MainModel.php
MainModel.getParser
public static function getParser($url, $contentDiv, $additionalSetting = false) { $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); $html = !$additionalSetting ? $html : $html->next_sibling(); $html = $html->outertext; $html = str_replace('&quot;', '\"', $html); $html = str_replace('&lt;', '&l-t;', $html); // handle '<' $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); $html = str_replace('&l-t;', '&lt;', $html); $html = HtmlDomParser::str_get_html($html); return $html; }
php
public static function getParser($url, $contentDiv, $additionalSetting = false) { $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); $html = !$additionalSetting ? $html : $html->next_sibling(); $html = $html->outertext; $html = str_replace('&quot;', '\"', $html); $html = str_replace('&lt;', '&l-t;', $html); // handle '<' $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); $html = str_replace('&l-t;', '&lt;', $html); $html = HtmlDomParser::str_get_html($html); return $html; }
[ "public", "static", "function", "getParser", "(", "$", "url", ",", "$", "contentDiv", ",", "$", "additionalSetting", "=", "false", ")", "{", "$", "html", "=", "HtmlDomParser", "::", "file_get_html", "(", "$", "url", ")", "->", "find", "(", "$", "contentD...
Get trimmed HtmlDomParser class. @param string $url URL of full MyAnimeList page @param string $contentDiv Specific area to be parsed @return \simplehtmldom_1_5\simple_html_dom
[ "Get", "trimmed", "HtmlDomParser", "class", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/MainModel.php#L80-L92
train
rl404/MAL-Scraper
src/MalScraper/Model/MainModel.php
MainModel.errorCheck
public static function errorCheck($model) { $className = self::getCleanClassName($model); if (strpos($className, 'Search') !== false) { if (strlen($model->_query) < 3) { $model->_error = 400; } } if (!$model->_error) { $header = self::getHeader($model->_url); if ($header == 200) { if ($className != 'UserListModel') { $additionalSetting = ($className == 'CharacterPeoplePictureModel'); $model->_parser = self::getParser($model->_url, $model->_parserArea, $additionalSetting); } } else { $model->_error = $header; } } }
php
public static function errorCheck($model) { $className = self::getCleanClassName($model); if (strpos($className, 'Search') !== false) { if (strlen($model->_query) < 3) { $model->_error = 400; } } if (!$model->_error) { $header = self::getHeader($model->_url); if ($header == 200) { if ($className != 'UserListModel') { $additionalSetting = ($className == 'CharacterPeoplePictureModel'); $model->_parser = self::getParser($model->_url, $model->_parserArea, $additionalSetting); } } else { $model->_error = $header; } } }
[ "public", "static", "function", "errorCheck", "(", "$", "model", ")", "{", "$", "className", "=", "self", "::", "getCleanClassName", "(", "$", "model", ")", ";", "if", "(", "strpos", "(", "$", "className", ",", "'Search'", ")", "!==", "false", ")", "{"...
Header error check. @param MainModel $model Any model @return void
[ "Header", "error", "check", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/MainModel.php#L101-L122
train
rl404/MAL-Scraper
src/MalScraper/Model/MainModel.php
MainModel.getCleanClassName
public static function getCleanClassName($model) { $className = get_class($model); $className = explode('\\', $className); return $className[count($className) - 1]; }
php
public static function getCleanClassName($model) { $className = get_class($model); $className = explode('\\', $className); return $className[count($className) - 1]; }
[ "public", "static", "function", "getCleanClassName", "(", "$", "model", ")", "{", "$", "className", "=", "get_class", "(", "$", "model", ")", ";", "$", "className", "=", "explode", "(", "'\\\\'", ",", "$", "className", ")", ";", "return", "$", "className...
Get clean class name. @param MainModel $model Any model @return string
[ "Get", "clean", "class", "name", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/MainModel.php#L131-L137
train
rl404/MAL-Scraper
src/MalScraper/Model/User/HistoryModel.php
HistoryModel.getAllInfo
private function getAllInfo() { $data = []; $history_area = $this->_parser->find('table', 0); if ($history_area) { foreach ($history_area->find('tr') as $history) { if ($history->find('td', 0)->class != 'borderClass') { continue; } $h_temp = []; $name_area = $history->find('td', 0); $h_temp['id'] = $this->getId($name_area); $h_temp['title'] = $this->getTitle($name_area); $h_temp['type'] = $this->getType($name_area); $h_temp['progress'] = $this->getProgress($name_area); $h_temp['date'] = $this->getDate($history); $data[] = $h_temp; } } return $data; }
php
private function getAllInfo() { $data = []; $history_area = $this->_parser->find('table', 0); if ($history_area) { foreach ($history_area->find('tr') as $history) { if ($history->find('td', 0)->class != 'borderClass') { continue; } $h_temp = []; $name_area = $history->find('td', 0); $h_temp['id'] = $this->getId($name_area); $h_temp['title'] = $this->getTitle($name_area); $h_temp['type'] = $this->getType($name_area); $h_temp['progress'] = $this->getProgress($name_area); $h_temp['date'] = $this->getDate($history); $data[] = $h_temp; } } return $data; }
[ "private", "function", "getAllInfo", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "history_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'table'", ",", "0", ")", ";", "if", "(", "$", "history_area", ")", "{", "foreach", "(",...
Get user history list. @return array
[ "Get", "user", "history", "list", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/HistoryModel.php#L143-L166
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getCleanInfo
private function getCleanInfo($info_type, $next_info) { $info_value = $next_info->plaintext; $clean_info_value = trim(str_replace($info_type, '', $info_value)); $clean_info_value = preg_replace("/([\s])+/", ' ', $clean_info_value); return str_replace([', add some', '?', 'Not yet aired', 'Unknown'], '', $clean_info_value); }
php
private function getCleanInfo($info_type, $next_info) { $info_value = $next_info->plaintext; $clean_info_value = trim(str_replace($info_type, '', $info_value)); $clean_info_value = preg_replace("/([\s])+/", ' ', $clean_info_value); return str_replace([', add some', '?', 'Not yet aired', 'Unknown'], '', $clean_info_value); }
[ "private", "function", "getCleanInfo", "(", "$", "info_type", ",", "$", "next_info", ")", "{", "$", "info_value", "=", "$", "next_info", "->", "plaintext", ";", "$", "clean_info_value", "=", "trim", "(", "str_replace", "(", "$", "info_type", ",", "''", ","...
Get clean other info. @param string $info_type @param \simplehtmldom_1_5\simple_html_dom $next_info @return string
[ "Get", "clean", "other", "info", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L283-L290
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getRelatedDetail
private function getRelatedDetail($r) { $related = []; $rel_anime_link = $r->href; $separated_anime_link = explode('/', $rel_anime_link); $related['id'] = $separated_anime_link[2]; $related['title'] = $r->plaintext; $related['type'] = $separated_anime_link[1]; return $related; }
php
private function getRelatedDetail($r) { $related = []; $rel_anime_link = $r->href; $separated_anime_link = explode('/', $rel_anime_link); $related['id'] = $separated_anime_link[2]; $related['title'] = $r->plaintext; $related['type'] = $separated_anime_link[1]; return $related; }
[ "private", "function", "getRelatedDetail", "(", "$", "r", ")", "{", "$", "related", "=", "[", "]", ";", "$", "rel_anime_link", "=", "$", "r", "->", "href", ";", "$", "separated_anime_link", "=", "explode", "(", "'/'", ",", "$", "rel_anime_link", ")", "...
Get related detail. @param \simplehtmldom_1_5\simple_html_dom $r @return array
[ "Get", "related", "detail", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L390-L401
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getStaffId
private function getStaffId($st) { $staff_id = $st->find('a', 0)->href; $staff_id = explode('/', $staff_id); return $staff_id[4]; }
php
private function getStaffId($st) { $staff_id = $st->find('a', 0)->href; $staff_id = explode('/', $staff_id); return $staff_id[4]; }
[ "private", "function", "getStaffId", "(", "$", "st", ")", "{", "$", "staff_id", "=", "$", "st", "->", "find", "(", "'a'", ",", "0", ")", "->", "href", ";", "$", "staff_id", "=", "explode", "(", "'/'", ",", "$", "staff_id", ")", ";", "return", "$"...
Get staff id. @param \simplehtmldom_1_5\simple_html_dom $st @return string
[ "Get", "staff", "id", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L489-L495
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getStaffName
private function getStaffName($st, $va = false) { if ($va) { return $st->find('a', 0)->plaintext; } return trim(preg_replace('/\s+/', ' ', $st->find('a', 0)->plaintext)); }
php
private function getStaffName($st, $va = false) { if ($va) { return $st->find('a', 0)->plaintext; } return trim(preg_replace('/\s+/', ' ', $st->find('a', 0)->plaintext)); }
[ "private", "function", "getStaffName", "(", "$", "st", ",", "$", "va", "=", "false", ")", "{", "if", "(", "$", "va", ")", "{", "return", "$", "st", "->", "find", "(", "'a'", ",", "0", ")", "->", "plaintext", ";", "}", "return", "trim", "(", "pr...
Get staff name. @param \simplehtmldom_1_5\simple_html_dom $st @param bool $va (Optional) @return string
[ "Get", "staff", "name", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L505-L512
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getStaffImage
private function getStaffImage($each_staff, $va = false) { if ($va) { $staff_image = $each_staff->find('table td', 1)->find('img', 0)->getAttribute('data-src'); } else { $staff_image = $each_staff->find('tr td', 0)->find('img', 0)->getAttribute('data-src'); } return Helper::imageUrlCleaner($staff_image); }
php
private function getStaffImage($each_staff, $va = false) { if ($va) { $staff_image = $each_staff->find('table td', 1)->find('img', 0)->getAttribute('data-src'); } else { $staff_image = $each_staff->find('tr td', 0)->find('img', 0)->getAttribute('data-src'); } return Helper::imageUrlCleaner($staff_image); }
[ "private", "function", "getStaffImage", "(", "$", "each_staff", ",", "$", "va", "=", "false", ")", "{", "if", "(", "$", "va", ")", "{", "$", "staff_image", "=", "$", "each_staff", "->", "find", "(", "'table td'", ",", "1", ")", "->", "find", "(", "...
Get staff image. @param \simplehtmldom_1_5\simple_html_dom $each_staff @param bool $va (Optional) @return string
[ "Get", "staff", "image", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L534-L543
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getReviewId
private function getReviewId($very_bottom_area) { $id = $very_bottom_area->find('a', 0)->href; $id = explode('?id=', $id); return $id[1]; }
php
private function getReviewId($very_bottom_area) { $id = $very_bottom_area->find('a', 0)->href; $id = explode('?id=', $id); return $id[1]; }
[ "private", "function", "getReviewId", "(", "$", "very_bottom_area", ")", "{", "$", "id", "=", "$", "very_bottom_area", "->", "find", "(", "'a'", ",", "0", ")", "->", "href", ";", "$", "id", "=", "explode", "(", "'?id='", ",", "$", "id", ")", ";", "...
Get review user. @param \simplehtmldom_1_5\simple_html_dom $very_bottom_area @return string
[ "Get", "review", "user", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L616-L622
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getReviewImage
private function getReviewImage($top_area) { $image = $top_area->find('table', 0); $image = $image->find('td', 0)->find('img', 0)->src; return Helper::imageUrlCleaner($image); }
php
private function getReviewImage($top_area) { $image = $top_area->find('table', 0); $image = $image->find('td', 0)->find('img', 0)->src; return Helper::imageUrlCleaner($image); }
[ "private", "function", "getReviewImage", "(", "$", "top_area", ")", "{", "$", "image", "=", "$", "top_area", "->", "find", "(", "'table'", ",", "0", ")", ";", "$", "image", "=", "$", "image", "->", "find", "(", "'td'", ",", "0", ")", "->", "find", ...
Get review image. @param \simplehtmldom_1_5\simple_html_dom $top_area @return string
[ "Get", "review", "image", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L645-L651
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getReviewHelpful
private function getReviewHelpful($top_area) { $helpful = $top_area->find('table', 0); $helpful = $helpful->find('td', 1)->find('strong', 0)->plaintext; return trim($helpful); }
php
private function getReviewHelpful($top_area) { $helpful = $top_area->find('table', 0); $helpful = $helpful->find('td', 1)->find('strong', 0)->plaintext; return trim($helpful); }
[ "private", "function", "getReviewHelpful", "(", "$", "top_area", ")", "{", "$", "helpful", "=", "$", "top_area", "->", "find", "(", "'table'", ",", "0", ")", ";", "$", "helpful", "=", "$", "helpful", "->", "find", "(", "'td'", ",", "1", ")", "->", ...
Get review helful. @param \simplehtmldom_1_5\simple_html_dom $top_area @return string
[ "Get", "review", "helful", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L660-L666
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getReviewEpisode
private function getReviewEpisode($top_area) { $episode = $top_area->find('div div', 1)->plaintext; $episode = str_replace(['episodes seen', 'chapters read'], '', $episode); return trim($episode); }
php
private function getReviewEpisode($top_area) { $episode = $top_area->find('div div', 1)->plaintext; $episode = str_replace(['episodes seen', 'chapters read'], '', $episode); return trim($episode); }
[ "private", "function", "getReviewEpisode", "(", "$", "top_area", ")", "{", "$", "episode", "=", "$", "top_area", "->", "find", "(", "'div div'", ",", "1", ")", "->", "plaintext", ";", "$", "episode", "=", "str_replace", "(", "[", "'episodes seen'", ",", ...
Get review episode seen. @param \simplehtmldom_1_5\simple_html_dom $top_area @return string
[ "Get", "review", "episode", "seen", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L692-L698
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getReviewScore
private function getReviewScore($bottom_area) { $score = []; $score_area = $bottom_area->find('table', 0); if ($score_area) { foreach ($score_area->find('tr') as $each_score) { $score_type = strtolower($each_score->find('td', 0)->plaintext); $score_value = $each_score->find('td', 1)->plaintext; $score[$score_type] = $score_value; } } return $score; }
php
private function getReviewScore($bottom_area) { $score = []; $score_area = $bottom_area->find('table', 0); if ($score_area) { foreach ($score_area->find('tr') as $each_score) { $score_type = strtolower($each_score->find('td', 0)->plaintext); $score_value = $each_score->find('td', 1)->plaintext; $score[$score_type] = $score_value; } } return $score; }
[ "private", "function", "getReviewScore", "(", "$", "bottom_area", ")", "{", "$", "score", "=", "[", "]", ";", "$", "score_area", "=", "$", "bottom_area", "->", "find", "(", "'table'", ",", "0", ")", ";", "if", "(", "$", "score_area", ")", "{", "forea...
Get review score. @param \simplehtmldom_1_5\simple_html_dom $bottom_area @return array
[ "Get", "review", "score", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L707-L720
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getRecomId
private function getRecomId($each_recom) { $id = $each_recom->find('a', 0)->href; $id = explode('/', $id); $id = explode('-', $id[5]); if ($id[0] == $this->_id) { return $id[1]; } else { return $id[0]; } }
php
private function getRecomId($each_recom) { $id = $each_recom->find('a', 0)->href; $id = explode('/', $id); $id = explode('-', $id[5]); if ($id[0] == $this->_id) { return $id[1]; } else { return $id[0]; } }
[ "private", "function", "getRecomId", "(", "$", "each_recom", ")", "{", "$", "id", "=", "$", "each_recom", "->", "find", "(", "'a'", ",", "0", ")", "->", "href", ";", "$", "id", "=", "explode", "(", "'/'", ",", "$", "id", ")", ";", "$", "id", "=...
Get recommendation id. @param \simplehtmldom_1_5\simple_html_dom $each_recom @return string
[ "Get", "recommendation", "id", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L772-L782
train
rl404/MAL-Scraper
src/MalScraper/Model/General/InfoModel.php
InfoModel.getRecomUser
private function getRecomUser($each_recom) { $user = $each_recom->find('.users', 0)->plaintext; $user = str_replace(['Users', 'User'], '', $user); return trim($user); }
php
private function getRecomUser($each_recom) { $user = $each_recom->find('.users', 0)->plaintext; $user = str_replace(['Users', 'User'], '', $user); return trim($user); }
[ "private", "function", "getRecomUser", "(", "$", "each_recom", ")", "{", "$", "user", "=", "$", "each_recom", "->", "find", "(", "'.users'", ",", "0", ")", "->", "plaintext", ";", "$", "user", "=", "str_replace", "(", "[", "'Users'", ",", "'User'", "]"...
Get recommendation user. @param \simplehtmldom_1_5\simple_html_dom $each_recom @return string
[ "Get", "recommendation", "user", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/InfoModel.php#L817-L823
train
rl404/MAL-Scraper
src/MalScraper/Model/Seasonal/SeasonModel.php
SeasonModel.getProducer
private function getProducer($producer_area) { $producer = []; $temp_producer = $producer_area->find('span[class=producer]', 0); foreach ($temp_producer->find('a') as $each_producer) { $temp_prod = []; $temp_prod['id'] = $this->getProducerId($each_producer); $temp_prod['name'] = $this->getProducerName($each_producer); $producer[] = $temp_prod; } return $producer; }
php
private function getProducer($producer_area) { $producer = []; $temp_producer = $producer_area->find('span[class=producer]', 0); foreach ($temp_producer->find('a') as $each_producer) { $temp_prod = []; $temp_prod['id'] = $this->getProducerId($each_producer); $temp_prod['name'] = $this->getProducerName($each_producer); $producer[] = $temp_prod; } return $producer; }
[ "private", "function", "getProducer", "(", "$", "producer_area", ")", "{", "$", "producer", "=", "[", "]", ";", "$", "temp_producer", "=", "$", "producer_area", "->", "find", "(", "'span[class=producer]'", ",", "0", ")", ";", "foreach", "(", "$", "temp_pro...
Get producer. @param \simplehtmldom_1_5\simple_html_dom $producer_area @return array
[ "Get", "producer", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Seasonal/SeasonModel.php#L113-L127
train
rl404/MAL-Scraper
src/MalScraper/Model/Seasonal/SeasonModel.php
SeasonModel.getGenre
private function getGenre($each_anime) { $genre = []; $genre_area = $each_anime->find('div[class="genres js-genre"]', 0); foreach ($genre_area->find('a') as $each_genre) { $genre[] = $each_genre->plaintext; } return $genre; }
php
private function getGenre($each_anime) { $genre = []; $genre_area = $each_anime->find('div[class="genres js-genre"]', 0); foreach ($genre_area->find('a') as $each_genre) { $genre[] = $each_genre->plaintext; } return $genre; }
[ "private", "function", "getGenre", "(", "$", "each_anime", ")", "{", "$", "genre", "=", "[", "]", ";", "$", "genre_area", "=", "$", "each_anime", "->", "find", "(", "'div[class=\"genres js-genre\"]'", ",", "0", ")", ";", "foreach", "(", "$", "genre_area", ...
Get genre. @param \simplehtmldom_1_5\simple_html_dom $each_anime @return array
[ "Get", "genre", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Seasonal/SeasonModel.php#L190-L199
train
rl404/MAL-Scraper
src/MalScraper/Model/Seasonal/SeasonModel.php
SeasonModel.getSynopsis
private function getSynopsis($each_anime) { $synopsis = $each_anime->find('div[class="synopsis js-synopsis"]', 0)->plaintext; preg_match('/(No synopsis)/', $synopsis, $temp_synopsis); if (!$temp_synopsis) { $synopsis = trim(preg_replace("/([\s])+/", ' ', $synopsis)); } else { $synopsis = ''; } return $synopsis; }
php
private function getSynopsis($each_anime) { $synopsis = $each_anime->find('div[class="synopsis js-synopsis"]', 0)->plaintext; preg_match('/(No synopsis)/', $synopsis, $temp_synopsis); if (!$temp_synopsis) { $synopsis = trim(preg_replace("/([\s])+/", ' ', $synopsis)); } else { $synopsis = ''; } return $synopsis; }
[ "private", "function", "getSynopsis", "(", "$", "each_anime", ")", "{", "$", "synopsis", "=", "$", "each_anime", "->", "find", "(", "'div[class=\"synopsis js-synopsis\"]'", ",", "0", ")", "->", "plaintext", ";", "preg_match", "(", "'/(No synopsis)/'", ",", "$", ...
Get synopsis. @param \simplehtmldom_1_5\simple_html_dom $each_anime @return string
[ "Get", "synopsis", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Seasonal/SeasonModel.php#L208-L219
train
rl404/MAL-Scraper
src/MalScraper/Model/Seasonal/SeasonModel.php
SeasonModel.getLicensor
private function getLicensor($each_anime) { $temp_licensor = $each_anime->find('div[class="synopsis js-synopsis"] .licensors', 0)->getAttribute('data-licensors'); $licensor = explode(',', $temp_licensor); return array_filter($licensor); }
php
private function getLicensor($each_anime) { $temp_licensor = $each_anime->find('div[class="synopsis js-synopsis"] .licensors', 0)->getAttribute('data-licensors'); $licensor = explode(',', $temp_licensor); return array_filter($licensor); }
[ "private", "function", "getLicensor", "(", "$", "each_anime", ")", "{", "$", "temp_licensor", "=", "$", "each_anime", "->", "find", "(", "'div[class=\"synopsis js-synopsis\"] .licensors'", ",", "0", ")", "->", "getAttribute", "(", "'data-licensors'", ")", ";", "$"...
Get licensor. @param \simplehtmldom_1_5\simple_html_dom $each_anime @return array
[ "Get", "licensor", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Seasonal/SeasonModel.php#L228-L234
train
rl404/MAL-Scraper
src/MalScraper/Model/Lists/AllGenreModel.php
AllGenreModel.getGenreCount
private function getGenreCount($each_genre) { $count = $each_genre->plaintext; preg_match('/\([0-9,]+\)/', $count, $cnt); $count = substr($cnt[0], 1, strlen($cnt[0]) - 2); return str_replace(',', '', $count); }
php
private function getGenreCount($each_genre) { $count = $each_genre->plaintext; preg_match('/\([0-9,]+\)/', $count, $cnt); $count = substr($cnt[0], 1, strlen($cnt[0]) - 2); return str_replace(',', '', $count); }
[ "private", "function", "getGenreCount", "(", "$", "each_genre", ")", "{", "$", "count", "=", "$", "each_genre", "->", "plaintext", ";", "preg_match", "(", "'/\\([0-9,]+\\)/'", ",", "$", "count", ",", "$", "cnt", ")", ";", "$", "count", "=", "substr", "("...
Get genre count. @param \simplehtmldom_1_5\simple_html_dom $each_genre @return string
[ "Get", "genre", "count", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Lists/AllGenreModel.php#L64-L71
train
rl404/MAL-Scraper
src/MalScraper/Model/Lists/AllGenreModel.php
AllGenreModel.getAllInfo
private function getAllInfo() { $data = []; foreach ($this->_parser->find('.genre-list a') as $each_genre) { $genre = []; $link = $each_genre->href; $link = explode('/', $link); $id = $link[3]; $genre['id'] = $id; $name = str_replace('_', ' ', $link[4]); $genre['name'] = $name; $genre['count'] = $this->getGenreCount($each_genre); $data[] = $genre; } return $data; }
php
private function getAllInfo() { $data = []; foreach ($this->_parser->find('.genre-list a') as $each_genre) { $genre = []; $link = $each_genre->href; $link = explode('/', $link); $id = $link[3]; $genre['id'] = $id; $name = str_replace('_', ' ', $link[4]); $genre['name'] = $name; $genre['count'] = $this->getGenreCount($each_genre); $data[] = $genre; } return $data; }
[ "private", "function", "getAllInfo", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_parser", "->", "find", "(", "'.genre-list a'", ")", "as", "$", "each_genre", ")", "{", "$", "genre", "=", "[", "]", ";", "$", ...
Get list of all genre. @return array
[ "Get", "list", "of", "all", "genre", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Lists/AllGenreModel.php#L78-L98
train
rl404/MAL-Scraper
src/MalScraper/Model/General/RecommendationModel.php
RecommendationModel.getSource
private function getSource($each_recom) { $source = []; $source_area = $each_recom->find('table tr', 0); $source['liked'] = $this->getSourceLiked($source_area, 0); $source['recommendation'] = $this->getSourceLiked($source_area, 1); return $source; }
php
private function getSource($each_recom) { $source = []; $source_area = $each_recom->find('table tr', 0); $source['liked'] = $this->getSourceLiked($source_area, 0); $source['recommendation'] = $this->getSourceLiked($source_area, 1); return $source; }
[ "private", "function", "getSource", "(", "$", "each_recom", ")", "{", "$", "source", "=", "[", "]", ";", "$", "source_area", "=", "$", "each_recom", "->", "find", "(", "'table tr'", ",", "0", ")", ";", "$", "source", "[", "'liked'", "]", "=", "$", ...
Get source. @param \simplehtmldom_1_5\simple_html_dom $each_recom @return array
[ "Get", "source", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/RecommendationModel.php#L109-L117
train
rl404/MAL-Scraper
src/MalScraper/Model/General/RecommendationModel.php
RecommendationModel.getSourceLiked
private function getSourceLiked($source_area, $key) { $liked = []; $source_area = $source_area->find('td', $key); $liked['id'] = $this->getSourceId($source_area); $liked['title'] = $this->getSourceTitle($source_area); $liked['type'] = $this->getType(); $liked['image'] = $this->getSourceImage($source_area); return $liked; }
php
private function getSourceLiked($source_area, $key) { $liked = []; $source_area = $source_area->find('td', $key); $liked['id'] = $this->getSourceId($source_area); $liked['title'] = $this->getSourceTitle($source_area); $liked['type'] = $this->getType(); $liked['image'] = $this->getSourceImage($source_area); return $liked; }
[ "private", "function", "getSourceLiked", "(", "$", "source_area", ",", "$", "key", ")", "{", "$", "liked", "=", "[", "]", ";", "$", "source_area", "=", "$", "source_area", "->", "find", "(", "'td'", ",", "$", "key", ")", ";", "$", "liked", "[", "'i...
Get source liked. @param \simplehtmldom_1_5\simple_html_dom $source_area @param int $key @return array
[ "Get", "source", "liked", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/RecommendationModel.php#L127-L137
train
rl404/MAL-Scraper
src/MalScraper/Model/User/FriendModel.php
FriendModel.getName
private function getName($f) { $name_temp = $f->find('a', 0)->href; $name_temp = explode('/', $name_temp); return $name_temp[4]; }
php
private function getName($f) { $name_temp = $f->find('a', 0)->href; $name_temp = explode('/', $name_temp); return $name_temp[4]; }
[ "private", "function", "getName", "(", "$", "f", ")", "{", "$", "name_temp", "=", "$", "f", "->", "find", "(", "'a'", ",", "0", ")", "->", "href", ";", "$", "name_temp", "=", "explode", "(", "'/'", ",", "$", "name_temp", ")", ";", "return", "$", ...
Get friend name. @param \simplehtmldom_1_5\simple_html_dom $f @return string
[ "Get", "friend", "name", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/FriendModel.php#L83-L89
train
rl404/MAL-Scraper
src/MalScraper/Model/User/FriendModel.php
FriendModel.getLastOnline
private function getLastOnline($f) { $last_online = $f->find('strong', 0)->parent()->parent()->next_sibling(); return trim($last_online->plaintext); }
php
private function getLastOnline($f) { $last_online = $f->find('strong', 0)->parent()->parent()->next_sibling(); return trim($last_online->plaintext); }
[ "private", "function", "getLastOnline", "(", "$", "f", ")", "{", "$", "last_online", "=", "$", "f", "->", "find", "(", "'strong'", ",", "0", ")", "->", "parent", "(", ")", "->", "parent", "(", ")", "->", "next_sibling", "(", ")", ";", "return", "tr...
Get friend last online. @param \simplehtmldom_1_5\simple_html_dom $f @return string
[ "Get", "friend", "last", "online", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/FriendModel.php#L98-L103
train
rl404/MAL-Scraper
src/MalScraper/Model/User/FriendModel.php
FriendModel.getFriendSince
private function getFriendSince($f) { $friend_since = $f->find('strong', 0)->parent()->parent()->next_sibling()->next_sibling(); $friend_since = str_replace('Friends since', '', $friend_since->plaintext); return trim($friend_since); }
php
private function getFriendSince($f) { $friend_since = $f->find('strong', 0)->parent()->parent()->next_sibling()->next_sibling(); $friend_since = str_replace('Friends since', '', $friend_since->plaintext); return trim($friend_since); }
[ "private", "function", "getFriendSince", "(", "$", "f", ")", "{", "$", "friend_since", "=", "$", "f", "->", "find", "(", "'strong'", ",", "0", ")", "->", "parent", "(", ")", "->", "parent", "(", ")", "->", "next_sibling", "(", ")", "->", "next_siblin...
Get friend since. @param \simplehtmldom_1_5\simple_html_dom $f @return string
[ "Get", "friend", "since", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/FriendModel.php#L112-L118
train
rl404/MAL-Scraper
src/MalScraper/Model/User/FriendModel.php
FriendModel.getAllInfo
private function getAllInfo() { $friend = []; $friend_area = $this->_parser->find('.majorPad', 0); if ($friend_area) { foreach ($friend_area->find('.friendHolder') as $f) { $f_dump = []; $f = $f->find('.friendBlock', 0); $f_dump['image'] = $this->getImage($f); $f_dump['name'] = $this->getName($f); $f_dump['last_online'] = $this->getLastOnline($f); $f_dump['friend_since'] = $this->getFriendSince($f); $friend[] = $f_dump; } } return $friend; }
php
private function getAllInfo() { $friend = []; $friend_area = $this->_parser->find('.majorPad', 0); if ($friend_area) { foreach ($friend_area->find('.friendHolder') as $f) { $f_dump = []; $f = $f->find('.friendBlock', 0); $f_dump['image'] = $this->getImage($f); $f_dump['name'] = $this->getName($f); $f_dump['last_online'] = $this->getLastOnline($f); $f_dump['friend_since'] = $this->getFriendSince($f); $friend[] = $f_dump; } } return $friend; }
[ "private", "function", "getAllInfo", "(", ")", "{", "$", "friend", "=", "[", "]", ";", "$", "friend_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'.majorPad'", ",", "0", ")", ";", "if", "(", "$", "friend_area", ")", "{", "foreach", ...
Get user friend list. @return array
[ "Get", "user", "friend", "list", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/FriendModel.php#L125-L144
train
rl404/MAL-Scraper
src/MalScraper/Model/Search/SearchAnimeMangaModel.php
SearchAnimeMangaModel.getScore
private function getScore($result_area) { $score = $result_area->find('td', 4)->plaintext; $score = trim($score); return $score == 'N/A' ? '' : $score; }
php
private function getScore($result_area) { $score = $result_area->find('td', 4)->plaintext; $score = trim($score); return $score == 'N/A' ? '' : $score; }
[ "private", "function", "getScore", "(", "$", "result_area", ")", "{", "$", "score", "=", "$", "result_area", "->", "find", "(", "'td'", ",", "4", ")", "->", "plaintext", ";", "$", "score", "=", "trim", "(", "$", "score", ")", ";", "return", "$", "s...
Get score. @param \simplehtmldom_1_5\simple_html_dom $result_area @return string
[ "Get", "score", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Search/SearchAnimeMangaModel.php#L167-L173
train
rl404/MAL-Scraper
src/MalScraper/Model/Lists/AllProducerModel.php
AllProducerModel.getProducerCount
private function getProducerCount($each_studio) { $count = $each_studio->plaintext; preg_match('/\([0-9,]+\)/', $count, $cnt); $count = substr($cnt[0], 1, strlen($cnt[0]) - 2); return str_replace(',', '', $count); }
php
private function getProducerCount($each_studio) { $count = $each_studio->plaintext; preg_match('/\([0-9,]+\)/', $count, $cnt); $count = substr($cnt[0], 1, strlen($cnt[0]) - 2); return str_replace(',', '', $count); }
[ "private", "function", "getProducerCount", "(", "$", "each_studio", ")", "{", "$", "count", "=", "$", "each_studio", "->", "plaintext", ";", "preg_match", "(", "'/\\([0-9,]+\\)/'", ",", "$", "count", ",", "$", "cnt", ")", ";", "$", "count", "=", "substr", ...
Get producer count. @param \simplehtmldom_1_5\simple_html_dom $each_studio @return string
[ "Get", "producer", "count", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Lists/AllProducerModel.php#L93-L100
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ReviewModel.php
ReviewModel.getReviewSource
private function getReviewSource($top_area, $bottom_area) { $source_area = $top_area->find('.mb8', 1); return [ 'type' => $this->getSourceType($source_area), 'id' => $this->getSourceId($source_area), 'title'=> $this->getSourceTitle($source_area), 'image'=> $this->getSourceImage($bottom_area), ]; }
php
private function getReviewSource($top_area, $bottom_area) { $source_area = $top_area->find('.mb8', 1); return [ 'type' => $this->getSourceType($source_area), 'id' => $this->getSourceId($source_area), 'title'=> $this->getSourceTitle($source_area), 'image'=> $this->getSourceImage($bottom_area), ]; }
[ "private", "function", "getReviewSource", "(", "$", "top_area", ",", "$", "bottom_area", ")", "{", "$", "source_area", "=", "$", "top_area", "->", "find", "(", "'.mb8'", ",", "1", ")", ";", "return", "[", "'type'", "=>", "$", "this", "->", "getSourceType...
Get review source. @param \simplehtmldom_1_5\simple_html_dom $top_area @param \simplehtmldom_1_5\simple_html_dom $bottom_area @return array
[ "Get", "review", "source", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ReviewModel.php#L89-L99
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ReviewModel.php
ReviewModel.getSourceType
private function getSourceType($source_area) { $type = $source_area->find('small', 0)->plaintext; $type = str_replace(['(', ')'], '', $type); $this->_type = strtolower($type); return strtolower($type); }
php
private function getSourceType($source_area) { $type = $source_area->find('small', 0)->plaintext; $type = str_replace(['(', ')'], '', $type); $this->_type = strtolower($type); return strtolower($type); }
[ "private", "function", "getSourceType", "(", "$", "source_area", ")", "{", "$", "type", "=", "$", "source_area", "->", "find", "(", "'small'", ",", "0", ")", "->", "plaintext", ";", "$", "type", "=", "str_replace", "(", "[", "'('", ",", "')'", "]", "...
Get source type. @param \simplehtmldom_1_5\simple_html_dom $source_area @return string
[ "Get", "source", "type", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ReviewModel.php#L108-L115
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ReviewModel.php
ReviewModel.getSourceId
private function getSourceId($source_area) { $id = $source_area->find('strong a', 0)->href; $id = explode('/', $id); return $id[4]; }
php
private function getSourceId($source_area) { $id = $source_area->find('strong a', 0)->href; $id = explode('/', $id); return $id[4]; }
[ "private", "function", "getSourceId", "(", "$", "source_area", ")", "{", "$", "id", "=", "$", "source_area", "->", "find", "(", "'strong a'", ",", "0", ")", "->", "href", ";", "$", "id", "=", "explode", "(", "'/'", ",", "$", "id", ")", ";", "return...
Get source id. @param \simplehtmldom_1_5\simple_html_dom $source_area @return string
[ "Get", "source", "id", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ReviewModel.php#L124-L130
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ReviewModel.php
ReviewModel.getReviewText
private function getReviewText($bottom_area) { $useless_area = $bottom_area->find('div', 0); $useless_area_1 = $useless_area->plaintext; $useless_area_2 = $useless_area->next_sibling()->plaintext; $useless_area_3 = $bottom_area->find('div[id^=revhelp_output]', 0)->plaintext; $useless_area_4 = $bottom_area->find('a[id^=reviewToggle]', 0) ? $bottom_area->find('a[id^=reviewToggle]', 0)->plaintext : null; $text = str_replace([$useless_area_1, $useless_area_2, $useless_area_3, $useless_area_4], '', $bottom_area->plaintext); $text = str_replace('&lt;', '<', $text); return trim(preg_replace('/\h+/', ' ', $text)); }
php
private function getReviewText($bottom_area) { $useless_area = $bottom_area->find('div', 0); $useless_area_1 = $useless_area->plaintext; $useless_area_2 = $useless_area->next_sibling()->plaintext; $useless_area_3 = $bottom_area->find('div[id^=revhelp_output]', 0)->plaintext; $useless_area_4 = $bottom_area->find('a[id^=reviewToggle]', 0) ? $bottom_area->find('a[id^=reviewToggle]', 0)->plaintext : null; $text = str_replace([$useless_area_1, $useless_area_2, $useless_area_3, $useless_area_4], '', $bottom_area->plaintext); $text = str_replace('&lt;', '<', $text); return trim(preg_replace('/\h+/', ' ', $text)); }
[ "private", "function", "getReviewText", "(", "$", "bottom_area", ")", "{", "$", "useless_area", "=", "$", "bottom_area", "->", "find", "(", "'div'", ",", "0", ")", ";", "$", "useless_area_1", "=", "$", "useless_area", "->", "plaintext", ";", "$", "useless_...
Get review text. @param \simplehtmldom_1_5\simple_html_dom $bottom_area @return string
[ "Get", "review", "text", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ReviewModel.php#L265-L276
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ProducerModel.php
ProducerModel.getAnimeImage
private function getAnimeImage($each_anime) { $image = $each_anime->find('div[class=image]', 0)->find('img', 0)->getAttribute('data-src'); return Helper::imageUrlCleaner($image); }
php
private function getAnimeImage($each_anime) { $image = $each_anime->find('div[class=image]', 0)->find('img', 0)->getAttribute('data-src'); return Helper::imageUrlCleaner($image); }
[ "private", "function", "getAnimeImage", "(", "$", "each_anime", ")", "{", "$", "image", "=", "$", "each_anime", "->", "find", "(", "'div[class=image]'", ",", "0", ")", "->", "find", "(", "'img'", ",", "0", ")", "->", "getAttribute", "(", "'data-src'", ")...
Get anime image. @param \simplehtmldom_1_5\simple_html_dom $each_anime @return string
[ "Get", "anime", "image", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ProducerModel.php#L97-L102
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ProducerModel.php
ProducerModel.getAnimeProducer
private function getAnimeProducer($producer_area) { $producer = []; $producer_area = $producer_area->find('span[class=producer]', 0); foreach ($producer_area->find('a') as $each_producer) { $temp_prod = []; $temp_prod['id'] = $this->getAnimeProducerId($each_producer); $temp_prod['name'] = $this->getAnimeProducerName($each_producer); $producer[] = $temp_prod; } return $producer; }
php
private function getAnimeProducer($producer_area) { $producer = []; $producer_area = $producer_area->find('span[class=producer]', 0); foreach ($producer_area->find('a') as $each_producer) { $temp_prod = []; $temp_prod['id'] = $this->getAnimeProducerId($each_producer); $temp_prod['name'] = $this->getAnimeProducerName($each_producer); $producer[] = $temp_prod; } return $producer; }
[ "private", "function", "getAnimeProducer", "(", "$", "producer_area", ")", "{", "$", "producer", "=", "[", "]", ";", "$", "producer_area", "=", "$", "producer_area", "->", "find", "(", "'span[class=producer]'", ",", "0", ")", ";", "foreach", "(", "$", "pro...
Get producer name. @param \simplehtmldom_1_5\simple_html_dom $producer_area @return array
[ "Get", "producer", "name", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ProducerModel.php#L138-L152
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ProducerModel.php
ProducerModel.getAnimeProducerId
private function getAnimeProducerId($each_producer) { $prod_id = $each_producer->href; $prod_id = explode('/', $prod_id); if ($this->_type == 'anime') { return $prod_id[3]; } return $prod_id[4]; }
php
private function getAnimeProducerId($each_producer) { $prod_id = $each_producer->href; $prod_id = explode('/', $prod_id); if ($this->_type == 'anime') { return $prod_id[3]; } return $prod_id[4]; }
[ "private", "function", "getAnimeProducerId", "(", "$", "each_producer", ")", "{", "$", "prod_id", "=", "$", "each_producer", "->", "href", ";", "$", "prod_id", "=", "explode", "(", "'/'", ",", "$", "prod_id", ")", ";", "if", "(", "$", "this", "->", "_t...
Get producer id. @param \simplehtmldom_1_5\simple_html_dom $each_producer @return string
[ "Get", "producer", "id", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ProducerModel.php#L161-L170
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ProducerModel.php
ProducerModel.getAnimeGenre
private function getAnimeGenre($each_anime) { $genre = []; $genre_area = $each_anime->find('div[class="genres js-genre"]', 0); foreach ($genre_area->find('a') as $each_genre) { $genre[] = $each_genre->plaintext; } return $genre; }
php
private function getAnimeGenre($each_anime) { $genre = []; $genre_area = $each_anime->find('div[class="genres js-genre"]', 0); foreach ($genre_area->find('a') as $each_genre) { $genre[] = $each_genre->plaintext; } return $genre; }
[ "private", "function", "getAnimeGenre", "(", "$", "each_anime", ")", "{", "$", "genre", "=", "[", "]", ";", "$", "genre_area", "=", "$", "each_anime", "->", "find", "(", "'div[class=\"genres js-genre\"]'", ",", "0", ")", ";", "foreach", "(", "$", "genre_ar...
Get anime genre. @param \simplehtmldom_1_5\simple_html_dom $each_anime @return array
[ "Get", "anime", "genre", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ProducerModel.php#L219-L228
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ProducerModel.php
ProducerModel.getAnimeLicensor
private function getAnimeLicensor($each_anime) { if ($this->_type == 'anime') { $licensor = $each_anime->find('div[class="synopsis js-synopsis"] .licensors', 0)->getAttribute('data-licensors'); $licensor = explode(',', $licensor); return array_filter($licensor); } else { $serialization = $each_anime->find('div[class="synopsis js-synopsis"] .serialization a', 0); return $serialization ? $serialization->plaintext : ''; } }
php
private function getAnimeLicensor($each_anime) { if ($this->_type == 'anime') { $licensor = $each_anime->find('div[class="synopsis js-synopsis"] .licensors', 0)->getAttribute('data-licensors'); $licensor = explode(',', $licensor); return array_filter($licensor); } else { $serialization = $each_anime->find('div[class="synopsis js-synopsis"] .serialization a', 0); return $serialization ? $serialization->plaintext : ''; } }
[ "private", "function", "getAnimeLicensor", "(", "$", "each_anime", ")", "{", "if", "(", "$", "this", "->", "_type", "==", "'anime'", ")", "{", "$", "licensor", "=", "$", "each_anime", "->", "find", "(", "'div[class=\"synopsis js-synopsis\"] .licensors'", ",", ...
Get anime licensor. @param \simplehtmldom_1_5\simple_html_dom $each_anime @return string|array
[ "Get", "anime", "licensor", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ProducerModel.php#L251-L263
train
rl404/MAL-Scraper
src/MalScraper/Model/General/ProducerModel.php
ProducerModel.getAnimeType
private function getAnimeType($info_area) { $type = $info_area->find('.info', 0)->plaintext; $type = explode('-', $type); return trim($type[0]); }
php
private function getAnimeType($info_area) { $type = $info_area->find('.info', 0)->plaintext; $type = explode('-', $type); return trim($type[0]); }
[ "private", "function", "getAnimeType", "(", "$", "info_area", ")", "{", "$", "type", "=", "$", "info_area", "->", "find", "(", "'.info'", ",", "0", ")", "->", "plaintext", ";", "$", "type", "=", "explode", "(", "'-'", ",", "$", "type", ")", ";", "r...
Get anime type. @param \simplehtmldom_1_5\simple_html_dom $info_area @return string
[ "Get", "anime", "type", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/General/ProducerModel.php#L272-L278
train
rl404/MAL-Scraper
src/MalScraper/Model/Additional/EpisodeModel.php
EpisodeModel.getAllInfo
private function getAllInfo() { $data = []; $episode_area = $this->_parser->find('table.episode_list', 0); if ($episode_area) { foreach ($episode_area->find('.episode-list-data') as $each_episode) { $temp = []; $temp['episode'] = $this->getEpisodeNo($each_episode); $temp['link'] = $this->getEpisodeLink($each_episode); $temp['title'] = $this->getEpisodeTitle($each_episode); $temp['japanese_title'] = $this->getEpisodeTitle($each_episode, true); $temp['aired'] = $this->getEpisodeAired($each_episode); $data[] = $temp; } } return $data; }
php
private function getAllInfo() { $data = []; $episode_area = $this->_parser->find('table.episode_list', 0); if ($episode_area) { foreach ($episode_area->find('.episode-list-data') as $each_episode) { $temp = []; $temp['episode'] = $this->getEpisodeNo($each_episode); $temp['link'] = $this->getEpisodeLink($each_episode); $temp['title'] = $this->getEpisodeTitle($each_episode); $temp['japanese_title'] = $this->getEpisodeTitle($each_episode, true); $temp['aired'] = $this->getEpisodeAired($each_episode); $data[] = $temp; } } return $data; }
[ "private", "function", "getAllInfo", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "episode_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'table.episode_list'", ",", "0", ")", ";", "if", "(", "$", "episode_area", ")", "{", "for...
Get anime videos. @return array
[ "Get", "anime", "videos", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/Additional/EpisodeModel.php#L156-L175
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getSns
private function getSns() { $sns = []; $sns_area = $this->_parser->find('.container-left .user-profile', 0); $sns_area = $sns_area->find('.user-profile-sns', 0); foreach ($sns_area->find('a') as $each_sns) { if ($each_sns->class != 'di-ib mb8') { $sns[] = $each_sns->href; } } return $sns; }
php
private function getSns() { $sns = []; $sns_area = $this->_parser->find('.container-left .user-profile', 0); $sns_area = $sns_area->find('.user-profile-sns', 0); foreach ($sns_area->find('a') as $each_sns) { if ($each_sns->class != 'di-ib mb8') { $sns[] = $each_sns->href; } } return $sns; }
[ "private", "function", "getSns", "(", ")", "{", "$", "sns", "=", "[", "]", ";", "$", "sns_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'.container-left .user-profile'", ",", "0", ")", ";", "$", "sns_area", "=", "$", "sns_area", "->", ...
Get user sns. @return array
[ "Get", "user", "sns", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L120-L132
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getFriend
private function getFriend() { $friend = []; $friend_area = $this->_parser->find('.container-left .user-profile', 0); $friend_area = $friend_area->find('.user-friends', 0); $friend_count = $friend_area->prev_sibling()->find('a', 0)->plaintext; preg_match('/\(\d+\)/', $friend_count, $friend_count); $friend['count'] = str_replace(['(', ')'], '', $friend_count[0]); $friend['data'] = []; foreach ($friend_area->find('a') as $f) { $temp_friend = []; $temp_friend['name'] = $f->plaintext; $temp_friend['image'] = Helper::imageUrlCleaner($f->getAttribute('data-bg')); $friend['data'][] = $temp_friend; } return $friend; }
php
private function getFriend() { $friend = []; $friend_area = $this->_parser->find('.container-left .user-profile', 0); $friend_area = $friend_area->find('.user-friends', 0); $friend_count = $friend_area->prev_sibling()->find('a', 0)->plaintext; preg_match('/\(\d+\)/', $friend_count, $friend_count); $friend['count'] = str_replace(['(', ')'], '', $friend_count[0]); $friend['data'] = []; foreach ($friend_area->find('a') as $f) { $temp_friend = []; $temp_friend['name'] = $f->plaintext; $temp_friend['image'] = Helper::imageUrlCleaner($f->getAttribute('data-bg')); $friend['data'][] = $temp_friend; } return $friend; }
[ "private", "function", "getFriend", "(", ")", "{", "$", "friend", "=", "[", "]", ";", "$", "friend_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'.container-left .user-profile'", ",", "0", ")", ";", "$", "friend_area", "=", "$", "friend_a...
Get user friend. @return array
[ "Get", "user", "friend", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L139-L160
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getAbout
private function getAbout() { $about_area = $this->_parser->find('.container-right', 0); $about = $about_area->find('table tr td div[class=word-break]', 0); return $about ? trim($about->innertext) : ''; }
php
private function getAbout() { $about_area = $this->_parser->find('.container-right', 0); $about = $about_area->find('table tr td div[class=word-break]', 0); return $about ? trim($about->innertext) : ''; }
[ "private", "function", "getAbout", "(", ")", "{", "$", "about_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'.container-right'", ",", "0", ")", ";", "$", "about", "=", "$", "about_area", "->", "find", "(", "'table tr td div[class=word-break]'...
Get user about. @return string
[ "Get", "user", "about", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L167-L173
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getStat
private function getStat($type) { $anime_stat = []; $right_area = $this->_parser->find('.container-right', 0); $stat_area = $right_area->find('.user-statistics', 0); if ($type == 'anime') { $a_stat_area = $stat_area->find('div[class="user-statistics-stats mt16"]', 0); } else { $a_stat_area = $stat_area->find('div[class="user-statistics-stats mt16"]', 1); } $a_stat_score = $a_stat_area->find('.stat-score', 0); $anime_stat['days'] = $this->getDays($a_stat_score); $anime_stat['mean_score'] = $this->getMeanScore($a_stat_score); $anime_stat['status'] = $this->getStatStatus($a_stat_area, $type); $anime_stat['history'] = $this->getHistory($right_area, $type); return $anime_stat; }
php
private function getStat($type) { $anime_stat = []; $right_area = $this->_parser->find('.container-right', 0); $stat_area = $right_area->find('.user-statistics', 0); if ($type == 'anime') { $a_stat_area = $stat_area->find('div[class="user-statistics-stats mt16"]', 0); } else { $a_stat_area = $stat_area->find('div[class="user-statistics-stats mt16"]', 1); } $a_stat_score = $a_stat_area->find('.stat-score', 0); $anime_stat['days'] = $this->getDays($a_stat_score); $anime_stat['mean_score'] = $this->getMeanScore($a_stat_score); $anime_stat['status'] = $this->getStatStatus($a_stat_area, $type); $anime_stat['history'] = $this->getHistory($right_area, $type); return $anime_stat; }
[ "private", "function", "getStat", "(", "$", "type", ")", "{", "$", "anime_stat", "=", "[", "]", ";", "$", "right_area", "=", "$", "this", "->", "_parser", "->", "find", "(", "'.container-right'", ",", "0", ")", ";", "$", "stat_area", "=", "$", "right...
Get user anime stat. @param string $type @return array
[ "Get", "user", "anime", "stat", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L182-L200
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getDays
private function getDays($a_stat_score) { $days = $a_stat_score->find('div', 0); $temp_days = $days->find('span', 0)->plaintext; return str_replace($temp_days, '', $days->plaintext); }
php
private function getDays($a_stat_score) { $days = $a_stat_score->find('div', 0); $temp_days = $days->find('span', 0)->plaintext; return str_replace($temp_days, '', $days->plaintext); }
[ "private", "function", "getDays", "(", "$", "a_stat_score", ")", "{", "$", "days", "=", "$", "a_stat_score", "->", "find", "(", "'div'", ",", "0", ")", ";", "$", "temp_days", "=", "$", "days", "->", "find", "(", "'span'", ",", "0", ")", "->", "plai...
Get days stat. @param \simplehtmldom_1_5\simple_html_dom $a_stat_score @return string
[ "Get", "days", "stat", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L209-L215
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getMeanScore
private function getMeanScore($a_stat_score) { $mean_score = $a_stat_score->find('div', 1); $temp_score = $mean_score->find('span', 0)->plaintext; return str_replace($temp_score, '', $mean_score->plaintext); }
php
private function getMeanScore($a_stat_score) { $mean_score = $a_stat_score->find('div', 1); $temp_score = $mean_score->find('span', 0)->plaintext; return str_replace($temp_score, '', $mean_score->plaintext); }
[ "private", "function", "getMeanScore", "(", "$", "a_stat_score", ")", "{", "$", "mean_score", "=", "$", "a_stat_score", "->", "find", "(", "'div'", ",", "1", ")", ";", "$", "temp_score", "=", "$", "mean_score", "->", "find", "(", "'span'", ",", "0", ")...
Get mean score stat. @param \simplehtmldom_1_5\simple_html_dom $a_stat_score @return string
[ "Get", "mean", "score", "stat", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L224-L230
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getStatStatus
private function getStatStatus($a_stat_area, $type) { $temp_stat = []; $a_stat_status = $a_stat_area->find('ul[class=stats-status]', 0); if ($type == 'anime') { $temp_stat['watching'] = $this->getStatStatusCount($a_stat_status, 0); $temp_stat['completed'] = $this->getStatStatusCount($a_stat_status, 1); $temp_stat['on_hold'] = $this->getStatStatusCount($a_stat_status, 2); $temp_stat['dropped'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['plan_to_watch'] = $this->getStatStatusCount($a_stat_status, 4); } else { $temp_stat['reading'] = $this->getStatStatusCount($a_stat_status, 0); $temp_stat['completed'] = $this->getStatStatusCount($a_stat_status, 1); $temp_stat['on_hold'] = $this->getStatStatusCount($a_stat_status, 2); $temp_stat['dropped'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['plan_to_read'] = $this->getStatStatusCount($a_stat_status, 4); } $a_stat_status = $a_stat_area->find('ul[class=stats-data]', 0); $temp_stat['total'] = $this->getStatStatusCount($a_stat_status, 1); if ($type == 'anime') { $temp_stat['rewatched'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['episode'] = $this->getStatStatusCount($a_stat_status, 5); } else { $temp_stat['reread'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['chapter'] = $this->getStatStatusCount($a_stat_status, 5); $temp_stat['volume'] = $this->getStatStatusCount($a_stat_status, 7); } return $temp_stat; }
php
private function getStatStatus($a_stat_area, $type) { $temp_stat = []; $a_stat_status = $a_stat_area->find('ul[class=stats-status]', 0); if ($type == 'anime') { $temp_stat['watching'] = $this->getStatStatusCount($a_stat_status, 0); $temp_stat['completed'] = $this->getStatStatusCount($a_stat_status, 1); $temp_stat['on_hold'] = $this->getStatStatusCount($a_stat_status, 2); $temp_stat['dropped'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['plan_to_watch'] = $this->getStatStatusCount($a_stat_status, 4); } else { $temp_stat['reading'] = $this->getStatStatusCount($a_stat_status, 0); $temp_stat['completed'] = $this->getStatStatusCount($a_stat_status, 1); $temp_stat['on_hold'] = $this->getStatStatusCount($a_stat_status, 2); $temp_stat['dropped'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['plan_to_read'] = $this->getStatStatusCount($a_stat_status, 4); } $a_stat_status = $a_stat_area->find('ul[class=stats-data]', 0); $temp_stat['total'] = $this->getStatStatusCount($a_stat_status, 1); if ($type == 'anime') { $temp_stat['rewatched'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['episode'] = $this->getStatStatusCount($a_stat_status, 5); } else { $temp_stat['reread'] = $this->getStatStatusCount($a_stat_status, 3); $temp_stat['chapter'] = $this->getStatStatusCount($a_stat_status, 5); $temp_stat['volume'] = $this->getStatStatusCount($a_stat_status, 7); } return $temp_stat; }
[ "private", "function", "getStatStatus", "(", "$", "a_stat_area", ",", "$", "type", ")", "{", "$", "temp_stat", "=", "[", "]", ";", "$", "a_stat_status", "=", "$", "a_stat_area", "->", "find", "(", "'ul[class=stats-status]'", ",", "0", ")", ";", "if", "("...
Get status stat. @param \simplehtmldom_1_5\simple_html_dom $a_stat_area @param string $type @return array
[ "Get", "status", "stat", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L240-L270
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getHistory
private function getHistory($right_area, $type) { $history = []; $a_history_area = $right_area->find('div[class="updates '.$type.'"]', 0); foreach ($a_history_area->find('.statistics-updates') as $each_history) { $temp_history = []; $history_data_area = $each_history->find('.data', 0); $temp_history['image'] = $this->getHistoryImage($each_history); $temp_history['id'] = $this->getHistoryId($history_data_area); $temp_history['title'] = $this->getHistoryTitle($history_data_area); $temp_history['date'] = $this->getHistoryDate($history_data_area); $progress = $this->getHistoryProgress($history_data_area); $temp_history = array_merge($temp_history, $progress); $history[] = $temp_history; } return $history; }
php
private function getHistory($right_area, $type) { $history = []; $a_history_area = $right_area->find('div[class="updates '.$type.'"]', 0); foreach ($a_history_area->find('.statistics-updates') as $each_history) { $temp_history = []; $history_data_area = $each_history->find('.data', 0); $temp_history['image'] = $this->getHistoryImage($each_history); $temp_history['id'] = $this->getHistoryId($history_data_area); $temp_history['title'] = $this->getHistoryTitle($history_data_area); $temp_history['date'] = $this->getHistoryDate($history_data_area); $progress = $this->getHistoryProgress($history_data_area); $temp_history = array_merge($temp_history, $progress); $history[] = $temp_history; } return $history; }
[ "private", "function", "getHistory", "(", "$", "right_area", ",", "$", "type", ")", "{", "$", "history", "=", "[", "]", ";", "$", "a_history_area", "=", "$", "right_area", "->", "find", "(", "'div[class=\"updates '", ".", "$", "type", ".", "'\"]'", ",", ...
Get history. @param \simplehtmldom_1_5\simple_html_dom $right_area @param string $type @return array
[ "Get", "history", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L293-L312
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getHistoryId
private function getHistoryId($history_data_area) { $id = $history_data_area->find('a', 0)->href; $id = explode('/', $id); return $id[4]; }
php
private function getHistoryId($history_data_area) { $id = $history_data_area->find('a', 0)->href; $id = explode('/', $id); return $id[4]; }
[ "private", "function", "getHistoryId", "(", "$", "history_data_area", ")", "{", "$", "id", "=", "$", "history_data_area", "->", "find", "(", "'a'", ",", "0", ")", "->", "href", ";", "$", "id", "=", "explode", "(", "'/'", ",", "$", "id", ")", ";", "...
Get history id. @param \simplehtmldom_1_5\simple_html_dom $history_data_area @return string
[ "Get", "history", "id", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L335-L341
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getFavList
private function getFavList($favorite_area, $type) { $favorite = []; $favorite_area = $favorite_area->find('ul[class="favorites-list '.$type.'"]', 0); if ($favorite_area) { foreach ($favorite_area->find('li') as $each_fav) { $temp_fav = []; $temp_fav['image'] = $this->getFavImage($each_fav); $temp_fav['id'] = $this->getFavId($each_fav); if ($type == 'anime' || $type == 'manga') { $temp_fav['title'] = $this->getFavTitle($each_fav); $temp_fav['type'] = $this->getFavType($each_fav); $temp_fav['year'] = $this->getFavYear($each_fav); } else { $temp_fav['name'] = $this->getFavTitle($each_fav); if ($type == 'characters') { $temp_fav['media_id'] = $this->getFavMedia($each_fav, 2); $temp_fav['media_title'] = $this->getFavMediaTitle($each_fav); $temp_fav['media_type'] = $this->getFavMedia($each_fav, 1); } } $favorite[] = $temp_fav; } } return $favorite; }
php
private function getFavList($favorite_area, $type) { $favorite = []; $favorite_area = $favorite_area->find('ul[class="favorites-list '.$type.'"]', 0); if ($favorite_area) { foreach ($favorite_area->find('li') as $each_fav) { $temp_fav = []; $temp_fav['image'] = $this->getFavImage($each_fav); $temp_fav['id'] = $this->getFavId($each_fav); if ($type == 'anime' || $type == 'manga') { $temp_fav['title'] = $this->getFavTitle($each_fav); $temp_fav['type'] = $this->getFavType($each_fav); $temp_fav['year'] = $this->getFavYear($each_fav); } else { $temp_fav['name'] = $this->getFavTitle($each_fav); if ($type == 'characters') { $temp_fav['media_id'] = $this->getFavMedia($each_fav, 2); $temp_fav['media_title'] = $this->getFavMediaTitle($each_fav); $temp_fav['media_type'] = $this->getFavMedia($each_fav, 1); } } $favorite[] = $temp_fav; } } return $favorite; }
[ "private", "function", "getFavList", "(", "$", "favorite_area", ",", "$", "type", ")", "{", "$", "favorite", "=", "[", "]", ";", "$", "favorite_area", "=", "$", "favorite_area", "->", "find", "(", "'ul[class=\"favorites-list '", ".", "$", "type", ".", "'\"...
Get favorite list. @param \simplehtmldom_1_5\simple_html_dom $favorite_area @param string $type @return array
[ "Get", "favorite", "list", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L418-L448
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getFavImage
private function getFavImage($each_fav) { $image = $each_fav->find('a', 0)->style; preg_match('/\'([^\'])*/', $image, $image); $image = substr($image[0], 1); return Helper::imageUrlCleaner($image); }
php
private function getFavImage($each_fav) { $image = $each_fav->find('a', 0)->style; preg_match('/\'([^\'])*/', $image, $image); $image = substr($image[0], 1); return Helper::imageUrlCleaner($image); }
[ "private", "function", "getFavImage", "(", "$", "each_fav", ")", "{", "$", "image", "=", "$", "each_fav", "->", "find", "(", "'a'", ",", "0", ")", "->", "style", ";", "preg_match", "(", "'/\\'([^\\'])*/'", ",", "$", "image", ",", "$", "image", ")", "...
Get favorite image. @param \simplehtmldom_1_5\simple_html_dom $each_fav @return string
[ "Get", "favorite", "image", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L457-L464
train
rl404/MAL-Scraper
src/MalScraper/Model/User/UserModel.php
UserModel.getFavId
private function getFavId($each_fav) { $id = $each_fav->find('a', 0)->href; $id = explode('/', $id); return $id[4]; }
php
private function getFavId($each_fav) { $id = $each_fav->find('a', 0)->href; $id = explode('/', $id); return $id[4]; }
[ "private", "function", "getFavId", "(", "$", "each_fav", ")", "{", "$", "id", "=", "$", "each_fav", "->", "find", "(", "'a'", ",", "0", ")", "->", "href", ";", "$", "id", "=", "explode", "(", "'/'", ",", "$", "id", ")", ";", "return", "$", "id"...
Get favorite id. @param \simplehtmldom_1_5\simple_html_dom $each_fav @return string
[ "Get", "favorite", "id", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Model/User/UserModel.php#L473-L479
train
rl404/MAL-Scraper
src/MalScraper/Helper/Helper.php
Helper.response
public static function response($response) { $result = []; if (is_numeric($response)) { header('HTTP/1.1 '.$response); $result['status'] = $response; $result['status_message'] = self::toResponse($response); $result['data'] = []; } else { header('HTTP/1.1 '. 200); $result['status'] = 200; $result['status_message'] = 'Success'; $result['data'] = self::superEncode($response); } $json_response = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); $json_response = str_replace('\\\\', '', $json_response); return $json_response; }
php
public static function response($response) { $result = []; if (is_numeric($response)) { header('HTTP/1.1 '.$response); $result['status'] = $response; $result['status_message'] = self::toResponse($response); $result['data'] = []; } else { header('HTTP/1.1 '. 200); $result['status'] = 200; $result['status_message'] = 'Success'; $result['data'] = self::superEncode($response); } $json_response = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); $json_response = str_replace('\\\\', '', $json_response); return $json_response; }
[ "public", "static", "function", "response", "(", "$", "response", ")", "{", "$", "result", "=", "[", "]", ";", "if", "(", "is_numeric", "(", "$", "response", ")", ")", "{", "header", "(", "'HTTP/1.1 '", ".", "$", "response", ")", ";", "$", "result", ...
Convert return result into http response. @param string|array $response @return string
[ "Convert", "return", "result", "into", "http", "response", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Helper/Helper.php#L38-L57
train
rl404/MAL-Scraper
src/MalScraper/Helper/Helper.php
Helper.superEncode
private static function superEncode($array) { if (is_array($array) && !empty($array)) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = self::superEncode($value); } else { $array[$key] = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); } } } return $array; }
php
private static function superEncode($array) { if (is_array($array) && !empty($array)) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = self::superEncode($value); } else { $array[$key] = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); } } } return $array; }
[ "private", "static", "function", "superEncode", "(", "$", "array", ")", "{", "if", "(", "is_array", "(", "$", "array", ")", "&&", "!", "empty", "(", "$", "array", ")", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ...
Convert characters to UTF-8. @param array|string $array @return array|string
[ "Convert", "characters", "to", "UTF", "-", "8", "." ]
3e378a60dfaaef94949bccce4ff06f9399869bee
https://github.com/rl404/MAL-Scraper/blob/3e378a60dfaaef94949bccce4ff06f9399869bee/src/MalScraper/Helper/Helper.php#L66-L79
train