idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
12,100 | public static function before ( $ fn ) { $ test_method = new BeforeHook ( InvocationContext :: getActive ( ) , $ fn ) ; $ test_method -> addToParent ( ) ; return $ test_method ; } | Adds a before callback to the active block . The active block should be a describe block . |
12,101 | public static function before_all ( $ fn ) { $ test_method = new BeforeAllHook ( InvocationContext :: getActive ( ) , $ fn ) ; $ test_method -> addToParent ( ) ; return $ test_method ; } | Adds a before_all callback to the active block . The active block should generally be a describe block . |
12,102 | protected static function getNameAndSkipFlag ( $ name ) { if ( $ name [ 0 ] == 'x' ) { return array ( substr ( $ name , 1 ) , true ) ; } else { return array ( self :: $ method_map [ $ name ] , false ) ; } } | Used to detect skipped versions of methods . |
12,103 | private function prepareAutoloaderFile ( ) { $ plain_name = pathinfo ( $ this -> getPlainPath ( ) , PATHINFO_BASENAME ) ; $ obfuscated_name = pathinfo ( $ this -> getObfuscatedPath ( ) , PATHINFO_BASENAME ) ; $ autoloader = $ this -> getPlainPath ( ) . DIRECTORY_SEPARATOR . 'autoloader.php' ; $ contents = file_get_cont... | Prepara os caminhos de carregamento para os arquivos do autoloader |
12,104 | protected function makeBackup ( ) { $ path_plain = $ this -> getPlainPath ( ) ; $ path_obfuscated = $ this -> getObfuscatedPath ( ) ; $ path_backup = $ this -> getBackupPath ( ) ; if ( is_dir ( $ path_backup ) == true ) { $ this -> getObfuscator ( ) -> addRuntimeMessage ( 'A previous backup already exists!' ) ; return ... | Efetua o backup dos arquivos originais e adiciona os ofuscados no lugar |
12,105 | protected function setupComposer ( ) { $ composer_file = $ this -> getComposerJsonFile ( ) ; $ contents = json_decode ( file_get_contents ( $ composer_file ) , true ) ; if ( ! isset ( $ contents [ 'autoload' ] [ 'files' ] ) ) { $ contents [ 'autoload' ] [ 'files' ] = [ ] ; } $ autoloader_file = $ this -> getAutoloaderF... | Configura o composer para usar os arquivos ofuscados no lugar dos originais . |
12,106 | public function compare ( DecimalNumber $ a , DecimalNumber $ b ) { if ( function_exists ( 'bccomp' ) ) { return $ this -> compareUsingBcMath ( $ a , $ b ) ; } return $ this -> compareWithoutBcMath ( $ a , $ b ) ; } | Compares two decimal numbers . |
12,107 | public function compareUsingBcMath ( DecimalNumber $ a , DecimalNumber $ b ) { return bccomp ( ( string ) $ a , ( string ) $ b , max ( $ a -> getExponent ( ) , $ b -> getExponent ( ) ) ) ; } | Compares two decimal numbers using BC Math |
12,108 | public function compareWithoutBcMath ( DecimalNumber $ a , DecimalNumber $ b ) { $ signCompare = $ this -> compareSigns ( $ a -> getSign ( ) , $ b -> getSign ( ) ) ; if ( $ signCompare !== 0 ) { return $ signCompare ; } $ result = $ this -> positiveCompare ( $ a , $ b ) ; if ( $ a -> isNegative ( ) ) { return - $ resul... | Compares two decimal numbers without using BC Math |
12,109 | private function positiveCompare ( DecimalNumber $ a , DecimalNumber $ b ) { $ intLengthCompare = $ this -> compareNumeric ( strlen ( $ a -> getIntegerPart ( ) ) , strlen ( $ b -> getIntegerPart ( ) ) ) ; if ( $ intLengthCompare !== 0 ) { return $ intLengthCompare ; } $ intPartCompare = $ this -> compareBinary ( $ a ->... | Compares two decimal numbers as positive regardless of sign . |
12,110 | public function addTable ( TableInterface $ table ) { $ table -> setSchema ( $ this ) ; $ this -> _tables [ $ table -> getName ( ) ] = $ table ; return $ this ; } | Adds a table to this schema |
12,111 | public function getCreateStatement ( ) { $ sql = [ ] ; foreach ( $ this -> tables as $ table ) { $ createTable = new CreateTable ( $ table -> getName ( ) ) ; $ createTable -> setAdapter ( $ this -> getAdapter ( ) ) ; $ createTable -> setColumns ( $ table -> getColumns ( ) ) ; $ createTable -> setConstraints ( $ table -... | Returns the SQL create statement form this schema |
12,112 | public function getFolder ( ) { if ( is_null ( $ this -> _folder ) ) { $ this -> _folder = new Folder ( array ( 'name' => $ this -> details -> getPath ( ) ) ) ; } return $ this -> _folder ; } | Retrurs this file folder . |
12,113 | public function write ( $ content , $ mode = self :: MODE_REPLACE ) { $ fileContent = $ this -> read ( ) ; switch ( $ mode ) { case self :: MODE_PREPEND : $ fileContent = $ content . PHP_EOL . $ fileContent ; break ; case self :: MODE_APPEND : $ fileContent .= PHP_EOL . $ content ; break ; case self :: MODE_REPLACE : d... | Write content to this file |
12,114 | private static function toNameId ( $ value , $ source , $ destination ) { $ nameId = array ( 'Format' => SAML2_Const :: NAMEID_PERSISTENT , 'Value' => $ value , ) ; if ( ! empty ( $ source ) ) { $ nameId [ 'NameQualifier' ] = $ source ; } if ( ! empty ( $ destination ) ) { $ nameId [ 'SPNameQualifier' ] = $ destination... | Convert the targeted ID to a SAML 2 . 0 name identifier element |
12,115 | protected function _parseColumns ( ) { $ parts = [ ] ; foreach ( $ this -> _sql -> getColumns ( ) as $ column ) { $ parts [ ] = $ this -> _parseColumn ( $ column ) ; } $ tableName = $ this -> _sql -> getTable ( ) ; return implode ( "; ALTER TABLE {$tableName} ADD COLUMN " , $ parts ) ; } | Parse column list for SQL create statement |
12,116 | private function _checkUnsupportedFeatures ( ) { $ addCons = $ this -> _sql -> getConstraints ( ) ; $ droppedCons = $ this -> _sql -> getDroppedConstraints ( ) ; $ droppedColumns = $ this -> _sql -> getDroppedColumns ( ) ; $ changedColumns = $ this -> _sql -> getChangedColumns ( ) ; return empty ( $ addCons ) && empty ... | Check alter table support |
12,117 | public function choice ( $ question , $ choices = array ( ) , $ allowedMultiple = false ) { $ this -> output -> writeln ( $ question ) ; $ this -> output -> writeln ( join ( ',' , $ choices ) ) ; $ answer = $ this -> input -> getInput ( ) ; $ valid = $ this -> validateChoices ( $ answer , $ choices , $ allowedMultiple ... | The choice question pick a single choice . |
12,118 | public function validateChoices ( $ answer , $ choices , $ allowedMultiple = false ) { if ( $ allowedMultiple ) { return $ this -> validateMultipleChoice ( $ answer , $ choices ) ; } else { return $ this -> validateSingleChoice ( $ answer , $ choices ) ; } } | Checks that the answer is present in the list of choices |
12,119 | public function validateMultipleChoice ( $ answer , $ choice ) { $ answers = explode ( ',' , $ answer ) ; foreach ( $ answers as $ ans ) { if ( ! in_array ( trim ( $ ans ) , $ choice ) ) { return false ; } $ formatedAnswers [ ] = trim ( $ ans ) ; } return $ formatedAnswers ; } | Validates multiple answers |
12,120 | public function setUpDispatcherDefaults ( ) { $ this -> dispatcher -> setDefaultTask ( 'Danzabar\CLI\Tasks\Utility\Help' ) ; $ this -> dispatcher -> setDefaultAction ( 'main' ) ; $ this -> dispatcher -> setTaskSuffix ( '' ) ; $ this -> dispatcher -> setActionSuffix ( '' ) ; } | Sets up the default settings for the dispatcher |
12,121 | public function registerDefaultHelpers ( ) { $ this -> helpers -> registerHelper ( 'question' , 'Danzabar\CLI\Tasks\Helpers\Question' ) ; $ this -> helpers -> registerHelper ( 'confirm' , 'Danzabar\CLI\Tasks\Helpers\Confirmation' ) ; $ this -> helpers -> registerHelper ( 'table' , 'Danzabar\CLI\Tasks\Helpers\Table' ) ;... | Registers the question confirmation and table helpers |
12,122 | public function start ( $ args = array ( ) ) { $ arg = $ this -> formatArgs ( $ args ) ; if ( ! empty ( $ arg ) ) { $ this -> prepper -> load ( $ arg [ 'task' ] ) -> loadParams ( $ arg [ 'params' ] ) -> prep ( $ arg [ 'action' ] ) ; $ this -> dispatcher -> setTaskName ( $ arg [ 'task' ] ) ; $ this -> dispatcher -> setA... | Start the app |
12,123 | public function add ( $ command ) { $ tasks = $ this -> prepper -> load ( get_class ( $ command ) ) -> describe ( ) ; $ this -> library -> add ( [ 'task' => $ tasks , 'class' => $ command ] ) ; return $ this ; } | Adds a command to the library |
12,124 | public function formatArgs ( $ args ) { unset ( $ args [ 0 ] ) ; if ( isset ( $ args [ 1 ] ) ) { $ command = explode ( ':' , $ args [ 1 ] ) ; unset ( $ args [ 1 ] ) ; } else { return array ( ) ; } try { $ action = ( isset ( $ command [ 1 ] ) ? $ command [ 1 ] : 'main' ) ; $ cmd = $ this -> library -> find ( $ command [... | Format the arguments into a useable state |
12,125 | public function compute ( DecimalNumber $ a , DecimalNumber $ b ) { if ( function_exists ( 'bcmul' ) ) { return $ this -> computeUsingBcMath ( $ a , $ b ) ; } return $ this -> computeWithoutBcMath ( $ a , $ b ) ; } | Performs the multiplication |
12,126 | public function computeUsingBcMath ( DecimalNumber $ a , DecimalNumber $ b ) { $ precision1 = $ a -> getPrecision ( ) ; $ precision2 = $ b -> getPrecision ( ) ; return new DecimalNumber ( ( string ) bcmul ( $ a , $ b , $ precision1 + $ precision2 ) ) ; } | Performs the multiplication using BC Math |
12,127 | public function computeWithoutBcMath ( DecimalNumber $ a , DecimalNumber $ b ) { $ aAsString = ( string ) $ a ; $ bAsString = ( string ) $ b ; if ( '0' === $ aAsString || '0' === $ bAsString ) { return new DecimalNumber ( '0' ) ; } if ( '1' === $ aAsString ) { return $ b ; } if ( '1' === $ bAsString ) { return $ a ; } ... | Performs the multiplication without BC Math |
12,128 | private function multiplyStrings ( $ topNumber , $ bottomNumber ) { $ topNumberLength = strlen ( $ topNumber ) ; $ bottomNumberLength = strlen ( $ bottomNumber ) ; if ( $ topNumberLength < $ bottomNumberLength ) { return $ this -> multiplyStrings ( $ bottomNumber , $ topNumber ) ; } $ stepNumber = 0 ; $ result = new De... | Multiplies two integer numbers as strings . |
12,129 | public function getMessages ( ) { $ messages = [ ] ; foreach ( $ this -> _elements as $ element ) { $ messages [ $ element -> getName ( ) ] = $ element -> getMessages ( ) ; } return $ messages ; } | Returns current error messages |
12,130 | public function getDescriptor ( ) { $ entityDescriptor = EntityManager :: getInstance ( ) -> get ( $ this ) ; return Manager :: getInstance ( ) -> get ( $ entityDescriptor ) ; } | Returns the model descriptor for this model class |
12,131 | public static function getList ( ) { $ model = new static ( ) ; $ fields = [ trim ( $ model -> getPrimaryKey ( ) , '_' ) , trim ( $ model -> getDisplayField ( ) , '_' ) ] ; $ rows = Sql :: createSql ( $ model -> getAdapter ( ) ) -> select ( $ model -> getTableName ( ) , $ fields ) -> limit ( null ) -> all ( ) ; $ list ... | Retrieves an array with primary keys and display fields |
12,132 | public function getFlashMessages ( ) { if ( is_null ( $ this -> _flashMessages ) ) { $ this -> _flashMessages = FlashMessages :: getInstance ( ) ; } return $ this -> _flashMessages ; } | Returns the flash messages object |
12,133 | public function connect ( ) { $ this -> _service = new SplMemcached ( ) ; $ this -> _service -> addServer ( $ this -> _host , $ this -> _port ) ; $ stats = $ this -> _service -> getStats ( ) ; if ( isset ( $ stats [ $ this -> _host . ":" . $ this -> _port ] ) ) { $ this -> _connected = true ; } else { throw new Service... | Connects to Memcached service . |
12,134 | public function disconnect ( ) { if ( $ this -> _isValidService ( ) ) { $ this -> getService ( ) -> quit ( ) ; $ this -> _service = null ; $ this -> _connected = false ; } return $ this ; } | Disconnects the Memcached service . |
12,135 | protected function _isValidService ( ) { $ isEmpty = empty ( $ this -> _service ) ; $ isInstance = $ this -> _service instanceof SplMemcached ; if ( $ this -> _connected && $ isInstance && ! $ isEmpty ) { return true ; } return false ; } | Checks if service is a valid instance and its connected . |
12,136 | public function offsetSet ( $ offset , $ value ) { if ( $ value instanceof AnnotationInterface ) { $ offset = $ value -> getName ( ) ; parent :: offsetSet ( $ offset , $ value ) ; } else { throw new Exception \ InvalidArgumentException ( "Only annotation objects can be added to an AnnotationsList." ) ; } } | Sets the value at the specified index to value |
12,137 | public function hasAnnotation ( $ name ) { $ name = str_replace ( '@' , '' , $ name ) ; foreach ( $ this as $ annotation ) { if ( $ annotation -> getName ( ) == $ name ) { return true ; } } return false ; } | Checks if current list contains an annotation with the provided name |
12,138 | public function getAnnotation ( $ name ) { if ( ! $ this -> hasAnnotation ( $ name ) ) { throw new Exception \ InvalidArgumentException ( "Annotation {$name} is not found in this list." ) ; } $ name = str_replace ( '@' , '' , $ name ) ; return $ this [ $ name ] ; } | Returns the annotation with the provided name |
12,139 | public static function isAdminBackend ( ) { $ controller = Controller :: curr ( ) ; if ( $ controller instanceof LeftAndMain || $ controller instanceof DevelopmentAdmin || $ controller instanceof DatabaseAdmin || ( class_exists ( 'DevBuildController' ) && $ controller instanceof DevBuildController ) ) { return true ; }... | Helper to detect if we are in admin or development admin |
12,140 | public static function include_jquery_ui ( ) { if ( self :: $ disabled || in_array ( 'jquery_ui' , self :: $ included ) ) { return ; } if ( self :: isAdminBackend ( ) ) { self :: $ included [ ] = 'jquery_ui' ; return ; } switch ( self :: config ( ) -> jquery_ui_version ) { case self :: JQUERY_UI_FRAMEWORK : $ path = TH... | Include jquery ui and theme |
12,141 | public static function include_entwine ( ) { if ( self :: $ disabled || in_array ( 'entwine' , self :: $ included ) ) { return ; } switch ( self :: config ( ) -> jquery_ui ) { case self :: JQUERY_FRAMEWORK : Requirements :: javascript ( 'framework/javascript/thirdparty/jquery-entwine/jquery.entwine-dist.js' ) ; Require... | Include jquery entwine |
12,142 | public function render ( ) { $ this -> engine -> parse ( $ this -> file ) ; $ output = $ this -> engine -> process ( $ this -> data ) ; return $ output ; } | Renders this view . |
12,143 | public function getEngine ( ) { if ( is_null ( $ this -> _engine ) ) { $ template = new Template ( $ this -> engineOptions ) ; $ this -> _engine = $ template -> initialize ( ) ; } return $ this -> _engine ; } | Returns the template engine for this view |
12,144 | public function getTables ( ) { if ( is_null ( $ this -> _tables ) ) { $ result = $ this -> _adapter -> query ( $ this -> _getTablesSql , [ $ this -> _adapter -> getSchemaName ( ) ] ) ; $ names = [ ] ; foreach ( $ result as $ table ) { $ names [ ] = $ table [ 'TABLE_NAME' ] ; } $ this -> _tables = $ names ; } return $ ... | Returns a list of table names |
12,145 | public function getSchema ( ) { $ schema = new Schema ( [ 'adapter' => $ this -> _adapter ] ) ; $ tables = $ this -> getTables ( ) ; foreach ( $ tables as $ tableName ) { $ schema -> addTable ( $ this -> getTable ( $ tableName ) ) ; } return $ schema ; } | Returns the schema for the given interface |
12,146 | protected function _getColumns ( $ tableName ) { $ params = [ ':schemaName' => $ this -> _adapter -> getSchemaName ( ) , ':tableName' => $ tableName ] ; return $ this -> _adapter -> query ( $ this -> _getColumnsSql , $ params ) ; } | Retrieve the column metadata from a given table |
12,147 | protected function _getColumnClass ( $ typeName ) { $ class = $ this -> _defaultColumn ; foreach ( $ this -> _typeExpressions as $ className => $ exp ) { if ( preg_match ( "/{$exp}/i" , $ typeName ) ) { $ class = $ className ; break ; } } return $ class ; } | Returns the column class name for a given column type |
12,148 | protected function _getConstraintClass ( $ type ) { $ class = null ; foreach ( $ this -> _constraintExpressions as $ className => $ exp ) { if ( preg_match ( "/{$exp}/i" , $ type ) ) { $ class = $ className ; break ; } } return $ class ; } | Retrieves the constraint class name for provided constraint type |
12,149 | private function addJoin ( $ type , $ join , $ on = null ) { $ join = "$type JOIN $join" ; if ( $ on !== null ) { $ join .= " ON $on" ; } $ this -> addParam ( $ join ) ; return $ this ; } | Joins a table |
12,150 | protected function selectQuerySource ( & $ query ) { foreach ( $ query [ 'trace' ] as $ i => & $ trace ) { $ isSource = true ; foreach ( $ this -> getNamespacesCutoff ( ) as $ namespace ) { $ namespace = trim ( $ namespace , '/\\' ) . '\\' ; if ( isset ( $ trace [ 'class' ] ) && strpos ( $ trace [ 'class' ] , $ namespa... | Marks selected trace item as query source based on invoking class namespace |
12,151 | public function getDuplicatedCount ( ) { $ count = 0 ; foreach ( $ this -> getQueries ( ) as $ query ) { if ( $ query [ 'count' ] > 1 ) { $ count += $ query [ 'count' ] - 1 ; } } return $ count ; } | Returns duplicated queries count . |
12,152 | public function getCallGraph ( ) { $ node = $ root = new Node ( array ( ) ) ; foreach ( $ this -> getQueries ( ) as $ query ) { foreach ( array_reverse ( $ query [ 'trace' ] ) as $ trace ) { $ node = $ node -> push ( $ trace ) ; } $ node -> addValue ( $ query ) ; $ node = $ root ; } return $ root ; } | Returns queries stacktrace tree root node |
12,153 | public function process ( $ path , $ replaceExisting = false , $ dryRun = false ) { $ iterator = $ this -> getFiles ( $ path ) ; foreach ( $ iterator as $ file ) { $ this -> processFile ( $ file , $ replaceExisting , $ dryRun ) ; } } | Processes a path and adds licenses |
12,154 | public function check ( $ path ) { foreach ( $ this -> getFiles ( $ path ) as $ file ) { $ this -> checkFile ( $ file ) ; } } | Checks a single file path |
12,155 | private function processFile ( SplFileInfo $ file , $ replaceExisting , $ dryRun ) { if ( $ file -> isDir ( ) ) { return ; } $ tokens = token_get_all ( $ file -> getContents ( ) ) ; $ licenseTokenIndex = $ this -> getLicenseTokenIndex ( $ tokens ) ; if ( null !== $ licenseTokenIndex && true === $ replaceExisting ) { $ ... | Processes a single file |
12,156 | private function removeExistingLicense ( SplFileInfo $ file , array $ tokens , $ licenseIndex , $ dryRun ) { $ this -> log ( sprintf ( '<fg=red>[-]</> Removing license header for <options=bold>%s</>' , $ file -> getRealPath ( ) ) ) ; if ( true === $ dryRun ) { return ; } $ content = $ file -> getContents ( ) ; $ remova... | Removes an existing license header from a file |
12,157 | private function checkFile ( SplFileInfo $ file ) { $ tokens = token_get_all ( $ file -> getContents ( ) ) ; $ licenseTokenIndex = $ this -> getLicenseTokenIndex ( $ tokens ) ; if ( $ licenseTokenIndex === null ) { $ this -> log ( sprintf ( 'Missing license header in "%s"' , $ file -> getRealPath ( ) ) ) ; } elseif ( $... | Checks the header of a single file |
12,158 | private function getLicenseTokenIndex ( array $ tokens ) { $ licenseTokenIndex = null ; foreach ( $ tokens as $ index => $ token ) { if ( $ token [ 0 ] === T_COMMENT ) { $ licenseTokenIndex = $ index ; } if ( $ token [ 0 ] === T_CLASS ) { break ; } } return $ licenseTokenIndex ; } | Returns the index of the first token that is a comment |
12,159 | private function getLicenseAsComment ( ) { $ license = explode ( PHP_EOL , $ this -> licenseHeader ) ; while ( end ( $ license ) === '' ) { array_pop ( $ license ) ; } reset ( $ license ) ; $ license = array_map ( function ( $ licenseLine ) { return rtrim ( ' * ' . $ licenseLine ) ; } , $ license ) ; $ license = implod... | Returns the license formatted as a comment |
12,160 | protected function parseTime ( $ value , $ format , $ locale = null , $ exactMatch = false ) { if ( ! Zend_Date :: isDate ( $ value , $ format ) ) { return null ; } $ valueObject = new Zend_Date ( $ value , $ format , $ locale ) ; if ( $ exactMatch && ( $ value !== $ valueObject -> get ( $ format ) ) ) { return null ; ... | Parses a time into a Zend_Date object |
12,161 | public function setValue ( $ val ) { if ( $ this -> getConfig ( 'use_strtotime' ) && ! empty ( $ val ) ) { if ( $ parsedTimestamp = strtotime ( $ val ) ) { $ parsedObj = new Zend_Date ( $ parsedTimestamp , Zend_Date :: TIMESTAMP ) ; $ val = $ parsedObj -> get ( $ this -> getConfig ( 'timeformat' ) ) ; unset ( $ parsedO... | Sets the internal value to ISO date format . |
12,162 | public function computeUsingBcMath ( DecimalNumber $ a , DecimalNumber $ b ) { $ precision1 = $ a -> getPrecision ( ) ; $ precision2 = $ b -> getPrecision ( ) ; return new DecimalNumber ( ( string ) bcadd ( $ a , $ b , max ( $ precision1 , $ precision2 ) ) ) ; } | Performs the addition using BC Math |
12,163 | public function computeWithoutBcMath ( DecimalNumber $ a , DecimalNumber $ b ) { if ( $ a -> isNegative ( ) ) { if ( $ b -> isNegative ( ) ) { return $ this -> computeWithoutBcMath ( $ a -> toPositive ( ) , $ b -> toPositive ( ) ) -> invert ( ) ; } return $ b -> minus ( $ a -> toPositive ( ) ) ; } if ( $ b -> isNegativ... | Performs the addition without BC Math |
12,164 | private function normalizeCoefficients ( DecimalNumber $ a , DecimalNumber $ b ) { $ exp1 = $ a -> getExponent ( ) ; $ exp2 = $ b -> getExponent ( ) ; $ coeff1 = $ a -> getCoefficient ( ) ; $ coeff2 = $ b -> getCoefficient ( ) ; if ( $ exp1 > $ exp2 ) { $ coeff2 = str_pad ( $ coeff2 , strlen ( $ coeff2 ) + $ exp1 - $ e... | Normalizes coefficients by adding leading or trailing zeroes as needed so that both are the same length |
12,165 | private function addStrings ( $ number1 , $ number2 , $ fractional = false ) { if ( '0' !== $ number1 [ 0 ] && '0' !== $ number2 [ 0 ] && strlen ( $ number1 ) <= $ this -> maxSafeIntStringSize && strlen ( $ number2 ) <= $ this -> maxSafeIntStringSize ) { return ( string ) ( ( int ) $ number1 + ( int ) $ number2 ) ; } $... | Adds two integer numbers as strings . |
12,166 | public function add ( DefinitionInterface $ definition ) { $ index = count ( $ this -> _names ) ; $ this -> _definitionSource [ $ index ] = $ definition ; $ this -> _names [ $ definition -> getName ( ) ] = $ index ; return $ this ; } | Adds a definition to the list of definitions |
12,167 | public function get ( $ name ) { $ definition = null ; if ( $ this -> has ( $ name ) ) { $ definition = $ this -> _definitionSource [ $ this -> _names [ $ name ] ] ; } return $ definition ; } | Returns the definition stored with the provided name |
12,168 | protected function _getTemplate ( ) { if ( is_null ( $ this -> _template ) ) { foreach ( $ this -> _map as $ method => $ className ) { if ( $ this -> _sql instanceof $ className ) { $ this -> _template = $ this -> $ method ( ) ; break ; } } } return $ this -> _template ; } | Creates the template for current SQL Object |
12,169 | public function contains ( $ member ) : bool { return $ member instanceof Resource && $ member -> uri && $ this -> findURI ( $ member -> uri ) >= 0 ; } | Check whether an equal member already exists in this Set . |
12,170 | public function findURI ( string $ uri ) { foreach ( $ this -> members as $ offset => $ member ) { if ( $ member -> uri == $ uri ) { return $ offset ; } } return - 1 ; } | Return the offset of a member Resource with given URI or - 1 . |
12,171 | public function isValid ( ) : bool { $ uris = [ ] ; foreach ( $ this -> members as $ member ) { $ uri = $ member -> uri ; if ( $ uri ) { if ( isset ( $ uris [ $ uri ] ) ) { return false ; } else { $ uris [ $ uri ] = true ; } } } return true ; } | Return whether this set does not contain same resources . |
12,172 | public function getConfiguration ( ) { if ( is_null ( $ this -> _configuration ) ) { $ this -> _configuration = Configuration :: get ( 'config' ) ; } return $ this -> _configuration ; } | Lazy loads configuration |
12,173 | public function getTranslatorService ( ) { if ( is_null ( $ this -> _translatorService ) ) { $ translator = new ZendTranslator ( ) ; $ translator -> addTranslationFilePattern ( $ this -> type , $ this -> basePath , '%s/' . $ this -> getMessageFile ( ) , $ this -> domain ) ; $ this -> _translatorService = $ translator ;... | Lazy loads zend translator |
12,174 | public function getMessageFile ( ) { $ name = $ this -> domain ; $ name .= $ this -> _types [ $ this -> type ] ; return $ name ; } | Returns the messages file name based on domain |
12,175 | public function translate ( $ message ) { $ locale = $ this -> configuration -> get ( 'i18n.locale' , $ this -> fallbackLocale ) ; return $ this -> getTranslatorService ( ) -> translate ( $ message , $ this -> domain , $ locale ) ; } | Returns the translation for the provided message |
12,176 | public function getAdapter ( ) { if ( is_null ( $ this -> _adapter ) ) { $ key = "db_{$this->configName}" ; $ this -> setAdapter ( $ this -> getContainer ( ) -> get ( $ key ) ) ; } return $ this -> _adapter ; } | Retrieves the current adapter |
12,177 | public function offsetSet ( $ lang , $ value ) { if ( DataType :: isLanguageOrRange ( $ lang ) ) { if ( is_null ( $ value ) ) { unset ( $ this -> members [ $ lang ] ) ; } else { $ this -> members [ $ lang ] = static :: checkMember ( $ value ) ; } } else { throw new InvalidArgumentException ( 'JSKOS\LanguageMap may only... | Set an value at the given language or language range . |
12,178 | public function connect ( ) { $ dsn = "sqlite:{$this->_file}" ; try { $ class = $ this -> _handlerClass ; $ this -> _handler = new $ class ( $ dsn ) ; $ this -> _handler -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; $ this -> _connected = true ; } catch ( \ Exception $ exp ) { throw new ServiceEx... | Connects to the database service |
12,179 | public function actionVideos ( $ id ) { $ video_gallery = $ this -> findModel ( $ id ) ; $ searchModel = $ this -> module -> manager -> createVideoGalleryItemSearch ( ) ; $ dataProvider = $ searchModel -> search ( $ _GET , $ id ) ; return $ this -> render ( 'video/index' , [ 'video_gallery' => $ video_gallery , 'dataPr... | Lists all VideoGallery videos models . |
12,180 | public function actionCreateVideo ( $ id ) { $ video_gallery = $ this -> findModel ( $ id ) ; $ model = $ this -> module -> manager -> createVideoGalleryItem ( [ 'scenario' => 'create' ] ) ; $ model -> loadDefaultValues ( ) ; if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) ) { $ model -> video_gallery_id... | Create video_gallery video |
12,181 | public function actionUpdateVideo ( $ id ) { $ model = $ this -> module -> manager -> findVideoGalleryItemById ( $ id ) ; if ( $ model === null ) { throw new NotFoundHttpException ( 'The requested video does not exist' ) ; } $ model -> scenario = 'update' ; $ video_gallery = $ this -> findModel ( $ model -> video_galle... | Updates an existing VideoGalleryItem model . If update is successful the browser will be redirected to the videos page . |
12,182 | public function actionDeleteVideo ( $ id ) { $ model = $ this -> module -> manager -> findVideoGalleryItemById ( $ id ) ; if ( $ model === null ) { throw new NotFoundHttpException ( 'The requested page does not exist' ) ; } $ model -> delete ( ) ; \ Yii :: $ app -> getSession ( ) -> setFlash ( 'video_gallery.success' ,... | Deletes an existing VideoGalleryItem model . If deletion is successful the browser will be redirected to the videos page . |
12,183 | public function get ( string $ name ) : JobInterface { if ( $ this -> has ( $ name ) ) { return $ this -> getOrMake ( $ name ) ; } throw new JobException ( "There is no such job: '$name'" ) ; } | Returns the job with the given name |
12,184 | public function add ( JobInterface $ job ) { if ( ! $ job -> getName ( ) ) { throw new JobException ( 'Add a name to the job.' ) ; } $ jobs [ $ job -> getName ( ) ] = $ job ; } | Adds a job to the pool |
12,185 | public function remove ( string $ name ) : bool { $ key = $ this -> makeCacheKey ( $ name ) ; $ this -> cache -> forget ( $ key ) ; unset ( $ this -> jobs [ $ name ] ) ; } | Removes a job from the pool |
12,186 | public function clear ( ) { foreach ( $ this -> jobs as $ name => $ job ) { $ key = $ this -> makeCacheKey ( $ name ) ; $ this -> cache -> forget ( $ key ) ; } $ this -> jobs = array ( ) ; } | Removes all jobs from the pool |
12,187 | public function all ( ) : array { $ jobs = array ( ) ; foreach ( $ this -> jobs as $ name => $ jobBag ) { $ jobs [ $ name ] = $ this -> getOrMake ( $ name ) ; } return $ jobs ; } | Returns an array with all jobs |
12,188 | public function run ( ) { $ now = time ( ) ; if ( $ this -> remainingCoolDown ( ) > 0 ) { return false ; } $ this -> cache -> forever ( $ this -> cacheKey , $ now ) ; $ counter = 0 ; foreach ( $ this -> jobs as $ name => $ jobBag ) { $ job = $ this -> getOrMake ( $ name ) ; $ key = $ this -> makeCacheKey ( $ name ) ; $... | Runs all jobs that do not have a cool down . Returns false or the number of executed jobs . |
12,189 | public function remainingCoolDown ( ) : int { $ now = time ( ) ; if ( $ this -> cache -> has ( $ this -> cacheKey ) ) { $ executedAt = $ this -> cache -> get ( $ this -> cacheKey ) ; $ remainingCoolDown = $ executedAt + $ this -> coolDown * 60 - $ now ; return max ( $ remainingCoolDown / 60 , 0 ) ; } return 0 ; } | Returns the number of minutes the job executor still is in cool down mode . Minimum is 0 . |
12,190 | protected function getOrMake ( string $ name ) : JobInterface { $ value = $ this -> jobs [ $ name ] ; if ( $ value instanceof JobInterface ) { return $ value ; } if ( is_string ( $ value ) ) { $ reflectionClass = new ReflectionClass ( $ value ) ; $ job = $ reflectionClass -> newInstance ( ) ; } else { $ job = $ value (... | If a job with the given name exists this method returns the job . If there is no such job yet it will create store and return it . |
12,191 | public function getClassAnnotations ( ) { if ( empty ( $ this -> _annotations [ 'class' ] ) ) { $ comment = $ this -> _getReflection ( ) -> getDocComment ( ) ; $ data = AnnotationParser :: getAnnotations ( $ comment ) ; $ classAnnotations = new AnnotationsList ( ) ; foreach ( $ data as $ name => $ parsedData ) { $ clas... | Retrieves the list of annotations from inspected class |
12,192 | public function getPropertyAnnotations ( $ property ) { if ( ! $ this -> hasProperty ( $ property ) ) { $ name = $ this -> _getReflection ( ) -> getName ( ) ; throw new Exception \ InvalidArgumentException ( "The class {$name} doesn't have a property called {$property}" ) ; } if ( empty ( $ this -> _annotations [ 'prop... | Retrieves the list of annotations from provided property |
12,193 | public function getMethodAnnotations ( $ method ) { if ( ! $ this -> hasMethod ( $ method ) ) { $ name = $ this -> _getReflection ( ) -> getName ( ) ; throw new Exception \ InvalidArgumentException ( "The class {$name} doesn't have a property called {$method}" ) ; } if ( empty ( $ this -> _annotations [ 'methods' ] [ $... | Retrieves the list of annotations of provided methods |
12,194 | public function getClassProperties ( ) { if ( empty ( $ this -> _properties ) ) { $ properties = $ this -> _getReflection ( ) -> getProperties ( ) ; foreach ( $ properties as $ property ) { $ this -> _properties [ ] = $ property -> getName ( ) ; } } return $ this -> _properties ; } | Retrieves the list of class properties . |
12,195 | public function getClassMethods ( ) { if ( empty ( $ this -> _methods ) ) { $ methods = $ this -> _getReflection ( ) -> getMethods ( ) ; foreach ( $ methods as $ method ) { $ this -> _methods [ ] = $ method -> getName ( ) ; } } return $ this -> _methods ; } | Retrieves the list of class methods |
12,196 | protected function _getReflection ( ) { if ( is_null ( $ this -> _reflection ) ) { $ this -> _reflection = new \ ReflectionClass ( $ this -> _class ) ; } return $ this -> _reflection ; } | Returns the reflection object for inspected class |
12,197 | protected function _createAnnotation ( $ name , $ parsedData ) { $ class = static :: $ _classMap [ 'default' ] ; if ( isset ( static :: $ _classMap [ $ name ] ) ) { $ class = static :: $ _classMap [ $ name ] ; } $ classReflection = new ReflectionClass ( $ class ) ; return $ classReflection -> newInstanceArgs ( [ $ name... | Creates the correct annotation object |
12,198 | public static function create ( $ dialect , SqlInterface $ sql ) { if ( array_key_exists ( $ dialect , static :: $ _map ) ) { return static :: _createDialect ( static :: $ _map [ $ dialect ] , $ sql ) ; } if ( class_exists ( $ dialect ) ) { if ( in_array ( static :: DIALECT_INTERFACE , class_implements ( $ dialect ) ) ... | Creates a dialect with provided SQL object |
12,199 | private static function _createDialect ( $ class , SqlInterface $ sql ) { $ reflection = new ReflectionClass ( $ class ) ; $ dialect = $ reflection -> newInstanceArgs ( ) ; $ dialect -> setSql ( $ sql ) ; return $ dialect ; } | Creates the dialect object with the given class name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.