Source of file AbstractFilter.php
Size: 2,310 Bytes - Last Modified: 2019-05-10T12:24:09+01:00
src/Utility/Filter/AbstractFilter.php
1234567891011121314151617181920212223242526272829303132333435363738
Covered by 1 test(s):
3940414243444546474849
Covered by 1 test(s):
505152535455565758596061
Covered by 1 test(s):
62
Covered by 1 test(s):
6364
Covered by 1 test(s):
6566676869707172737475
Covered by 2 test(s):
76
Covered by 2 test(s):
7778
Covered by 2 test(s):
798081
| <?php /** * Copyright 2016 University of Liverpool * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace pgb_liv\php_ms\Utility\Filter; use pgb_liv\php_ms\Core\Peptide; use pgb_liv\php_ms\Core\Spectra\IonInterface; /** * Abstract class containing generic filtering methods * * @author Andrew Collins */ abstract class AbstractFilter { /** * Returns true if the Peptide matches the filter criteria, else false * * @param Peptide $peptide * Peptide object to filter */ public function isValidPeptide(Peptide $peptide) { throw new \BadMethodCallException("isValidPeptide is not defined for this instance."); } /** * Returns true if the SpectraEntry matches the filter criteria, else false * * @param IonInterface $peptide * Ion object to filter */ public function isValidSpectra(IonInterface $spectra) { throw new \BadMethodCallException("isValidSpectra is not defined for this instance."); } /** * Filters an array of peptides and returns an array of peptides which match the filter criteria * * @param Peptide[] $peptides * An array of Peptide elements * @return Peptide[] */ public function filterPeptide(array $peptides) { return array_filter($peptides, array( $this, 'isValidPeptide' )); } /** * Filters an array of spectra and returns an array of spectra which match the filter criteria * * @param IonInterface[] $spectra * An array of spectra elements */ public function filterSpectra(array $spectra) { return array_filter($spectra, array( $this, 'isValidSpectra' )); } } |