source: sandbox/expresso-solr/expressoMail1_2/inc/solrclient/library/Solarium/Version.php @ 7576

Revision 7576, 4.9 KB checked in by adir, 11 years ago (diff)

Ticket #000 - Adicionando a integracao de buscas com Solr na base a ser isnerida na comunidade

Line 
1<?php
2/**
3 * Copyright 2011 Bas de Nooijer. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 *    this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 *    this listof conditions and the following disclaimer in the documentation
13 *    and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 *
27 * The views and conclusions contained in the software and documentation are
28 * those of the authors and should not be interpreted as representing official
29 * policies, either expressed or implied, of the copyright holder.
30 *
31 * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
32 * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
33 * @link http://www.solarium-project.org/
34 *
35 * @package Solarium
36 */
37
38/**
39 * Version indicator
40 *
41 * This class can be used to check the library version within your code. This
42 * can be important if you rely on a minimal version for the features you use.
43 *
44 * @package Solarium
45 */
46class Solarium_Version
47{
48
49    /**
50     * Version number of the Solarium library
51     *
52     * The version is built up in this format: major.minor.mini
53     *
54     * A major release is used for significant release with architectural
55     * changes and changes that might break backwards compatibility
56     *
57     * A minor release adds and enhances features, and might also contain
58     * bugfixes. It should be backwards compatible, or the incompatibilities
59     * should be clearly documented with the release.
60     *
61     * A mini release only contains bugfixes to existing features and is always
62     * backwards compatible.
63     *
64     * If you develop your application to a specific Solarium version it is best
65     * to check for that exact major and minor version, leaving the mini version
66     * open to allow for upgrades in case of bugfixes.
67     *
68     * @see checkExact()
69     * @see checkMinimal()
70     *
71     * @var string
72     */
73    const VERSION = '2.4.0';
74
75
76    /**
77     * Check for an exact version
78     *
79     * This method can check for all three versioning levels, but they are
80     * optional. If you only care for major and minor versions you can use
81     * something like '1.0' as input. Or '1' if you only want to check a major
82     * version.
83     *
84     * For each level that is checked the input has to be exactly the same as
85     * the actual version. Some examples:
86     *
87     * The if the version is 1.2.3 the following checks would return true:
88     * - 1 (only major version is checked)
89     * - 1.2 (only major and minor version are checked)
90     * - 1.2.3 (full version is checked)
91     *
92     * These values will return false:
93     * - 1.0 (lower)
94     * - 1.2.4 (higher)
95     *
96     *
97     * @internal a string compare is used instead of version_compare because
98     *  version_compare returns false for a compare of 1.0.0 with 1.0
99     *
100     * @param string $version
101     * @return boolean
102     */
103    static public function checkExact($version)
104    {
105        return (substr(self::VERSION, 0, strlen($version)) == $version);
106    }
107
108
109    /**
110     * Check for a minimal version
111     *
112     * This method can check for all three versioning levels, but they are
113     * optional. If you only care for major and minor versions you can use
114     * something like '1.0' as input. Or '1' if you only want to check a major
115     * version.
116     *
117     * For each level that is checked the actual value needs to be the same or
118     * higher. Some examples:
119     *
120     * The if the version is 1.2.3 the following checks would return true:
121     * - 1.2.3 (the same)
122     * - 1 (the actual version is higher)
123     *
124     * These values will return false:
125     * - 2 (the actual version is lower)
126     * - 1.3 (the actual version is lower)
127     *
128     * @param string $version
129     * @return boolean
130     */
131    static public function checkMinimal($version)
132    {
133        return version_compare(self::VERSION, $version, '>=');
134    }
135
136}
Note: See TracBrowser for help on using the repository browser.