• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

podio-community / podio-php / 5730982429

pending completion
5730982429

push

github

web-flow
Merge pull request #233 from podio-community/232-improvements-beta

fix: make podio_client first parameter of functions + remove podio_client member from models

235 of 235 new or added lines in 67 files covered. (100.0%)

916 of 2104 relevant lines covered (43.54%)

32.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.67
/models/PodioFile.php
1
<?php
2
/**
3
 * @see https://developers.podio.com/doc/files
4
 */
5
class PodioFile extends PodioObject
6
{
7
    public function __construct($attributes = array())
8
    {
9
        parent::__construct();
44✔
10
        $this->property('file_id', 'integer', array('id' => true));
44✔
11
        $this->property('link', 'string');
44✔
12
        $this->property('perma_link', 'string');
44✔
13
        $this->property('thumbnail_link', 'string');
44✔
14
        $this->property('hosted_by', 'string');
44✔
15
        $this->property('name', 'string');
44✔
16
        $this->property('description', 'string');
44✔
17
        $this->property('mimetype', 'string');
44✔
18
        $this->property('size', 'integer');
44✔
19
        $this->property('context', 'hash');
44✔
20
        $this->property('created_on', 'datetime');
44✔
21
        $this->property('rights', 'array');
44✔
22

23
        $this->has_one('created_by', 'ByLine');
44✔
24
        $this->has_one('created_via', 'Via');
44✔
25
        $this->has_many('replaces', 'File');
44✔
26

27
        $this->init($attributes);
44✔
28
    }
29

30
    private function get_download_link($size = null)
31
    {
32
        return $size ? ($this->link . '/' . $size) : $this->link;
×
33
    }
34

35
    /**
36
     * Returns the raw bytes of a file. Beware: This is not a static method.
37
     * It can only be used after you have a PodioFile object.
38
     */
39
    public function get_raw(PodioClient $podio_client, $size = null)
40
    {
41
        return $podio_client->get($this->get_download_link($size), array(), array('file_download' => true))->body;
×
42
    }
43

44
    /**
45
     * Returns the raw bytes of a file. Beware: This is not a static method.
46
     * It can only be used after you have a PodioFile object.
47
     *
48
     * In contrast to get_raw this method does use minimal memory (the result is stored in php://temp)
49
     * @return resource pointing at start of body (use fseek($resource, 0) to get headers as well)
50
     */
51
    public function get_raw_as_resource(PodioClient $podio_client, $size = null)
52
    {
53
        /** @noinspection PhpIncompatibleReturnTypeInspection */
54
        return $podio_client->get($this->get_download_link($size), array(), array('file_download' => true, 'return_raw_as_resource_only' => true));
×
55
    }
56

57
    /**
58
     * @see https://developers.podio.com/doc/files/upload-file-1004361
59
     */
60
    public static function upload(PodioClient $podio_client, $file_path, $file_name)
61
    {
62
        return self::member($podio_client, $podio_client->post("/file/", array('filename' => $file_name, 'filepath' => $file_path), array('upload' => true, 'filesize' => filesize($file_path))));
×
63
    }
64

65
    /**
66
     * @see https://developers.podio.com/doc/files/get-file-22451
67
     */
68
    public static function get(PodioClient $podio_client, $file_id)
69
    {
70
        return self::member($podio_client, $podio_client->get("/file/{$file_id}"));
×
71
    }
72

73
    /**
74
     * @see https://developers.podio.com/doc/files/get-files-on-app-22472
75
     */
76
    public static function get_for_app(PodioClient $podio_client, $app_id, $attributes = array())
77
    {
78
        return self::listing($podio_client, $podio_client->get("/file/app/{$app_id}/", $attributes));
×
79
    }
80

81
    /**
82
     * @see https://developers.podio.com/doc/files/get-files-on-space-22471
83
     */
84
    public static function get_for_space(PodioClient $podio_client, $space_id, $attributes = array())
85
    {
86
        return self::listing($podio_client, $podio_client->get("/file/space/{$space_id}/", $attributes));
×
87
    }
88

89
    /**
90
     * @see https://developers.podio.com/doc/files/attach-file-22518
91
     */
92
    public static function attach(PodioClient $podio_client, $file_id, $attributes = array(), $options = array())
93
    {
94
        $url = $podio_client->url_with_options("/file/{$file_id}/attach", $options);
×
95
        return $podio_client->post($url, $attributes);
×
96
    }
97

98
    /**
99
     * @see https://developers.podio.com/doc/files/replace-file-22450
100
     */
101
    public static function replace(PodioClient $podio_client, $file_id, $attributes = array())
102
    {
103
        return $podio_client->post("/file/{$file_id}/replace", $attributes);
×
104
    }
105

106
    /**
107
     * @see https://developers.podio.com/doc/files/copy-file-89977
108
     */
109
    public static function copy(PodioClient $podio_client, $file_id)
110
    {
111
        return self::member($podio_client, $podio_client->post("/file/{$file_id}/copy"));
×
112
    }
113

114
    /**
115
     * @see https://developers.podio.com/doc/files/get-files-4497983
116
     */
117
    public static function get_all(PodioClient $podio_client, $attributes = array())
118
    {
119
        return self::listing($podio_client, $podio_client->get("/file/", $attributes));
×
120
    }
121

122
    /**
123
     * @see https://developers.podio.com/doc/files/delete-file-22453
124
     */
125
    public static function delete(PodioClient $podio_client, $file_id)
126
    {
127
        return $podio_client->delete("/file/{$file_id}");
×
128
    }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc